Make this test suite contingent on the availability of Conch

This commit is contained in:
Jean-Paul Calderone 2019-08-14 09:03:36 -04:00
parent eb751baeef
commit f435b54a8a

View File

@ -12,18 +12,15 @@ from allmydata.util import deferredutil
conch_interfaces = None
sftp = None
sftpd = None
have_pycrypto = False
try:
from Crypto import Util
Util # hush pyflakes
have_pycrypto = True
except ImportError:
pass
if have_pycrypto:
try:
from twisted.conch import interfaces as conch_interfaces
from twisted.conch.ssh import filetransfer as sftp
from allmydata.frontends import sftpd
except ImportError as e:
conch_unavailable_reason = e
else:
conch_unavailable_reason = None
from allmydata.interfaces import IDirectoryNode, ExistingChildError, NoSuchChildError
from allmydata.mutable.common import NotWriteableError
@ -38,8 +35,8 @@ from allmydata.test.common_util import ReallyEqualMixin
class Handler(GridTestMixin, ShouldFailMixin, ReallyEqualMixin, unittest.TestCase):
"""This is a no-network unit test of the SFTPUserHandler and the abstractions it uses."""
if not have_pycrypto:
skip = "SFTP support requires pycrypto, which is not installed"
if conch_unavailable_reason:
skip = "SFTP support requires Twisted Conch which is not available: {}".format(e)
def shouldFailWithSFTPError(self, expected_code, which, callable, *args, **kwargs):
assert isinstance(expected_code, int), repr(expected_code)