python-unittest

Python unit tests run function after all test

怎甘沉沦 提交于 2020-12-08 05:52:24
问题 I need to test smth on python via ssh. I don't want to make ssh connection for every test, because it is to long, I have written this: class TestCase(unittest.TestCase): client = None def setUp(self): if not hasattr(self.__class__, 'client') or self.__class__.client is None: self.__class__.client = paramiko.SSHClient() self.__class__.client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) self.__class__.client.connect(hostname=consts.get_host(), port=consts.get_port(), username=consts

Python unit tests run function after all test

[亡魂溺海] 提交于 2020-12-08 05:52:10
问题 I need to test smth on python via ssh. I don't want to make ssh connection for every test, because it is to long, I have written this: class TestCase(unittest.TestCase): client = None def setUp(self): if not hasattr(self.__class__, 'client') or self.__class__.client is None: self.__class__.client = paramiko.SSHClient() self.__class__.client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) self.__class__.client.connect(hostname=consts.get_host(), port=consts.get_port(), username=consts

python - unittest - ImportError: Start directory is not importable

非 Y 不嫁゛ 提交于 2020-08-04 03:26:23
问题 I'm following python unittest to make some test and use discover function to pack tests to a suite. However when I try to run the test with unittest, I get this error: Traceback (most recent call last): File "D:/Project/run_tests.py", line 12, in <module> suite2 = unittest.defaultTestLoader.discover(dir2, pattern='test*.py') File "C:\Python\Python36-32\lib\unittest\loader.py", line 338, in discover raise ImportError('Start directory is not importable: %r' % start_dir) ImportError: Start

python - unittest - ImportError: Start directory is not importable

不打扰是莪最后的温柔 提交于 2020-08-04 03:23:19
问题 I'm following python unittest to make some test and use discover function to pack tests to a suite. However when I try to run the test with unittest, I get this error: Traceback (most recent call last): File "D:/Project/run_tests.py", line 12, in <module> suite2 = unittest.defaultTestLoader.discover(dir2, pattern='test*.py') File "C:\Python\Python36-32\lib\unittest\loader.py", line 338, in discover raise ImportError('Start directory is not importable: %r' % start_dir) ImportError: Start