據nosetest's API documentation,有一個LazySuite()
類,這是nosetest的LazySuite應該如何使用?
class nose.suite.LazySuite(tests=())
A suite that may use a generator as its list of tests
但是,我找不到這個測試發生器應該如何看起來像任何例子。我試着寫一個產生測試用例nosetest的測試發現,當人會使用,它傳遞給LazySuite
構造方式如下:
import nose
import nose.suite
data = [
['a', 'b', 'c'],
['1', '2', '3']
]
def check_data_list(data_list):
assert data_list[0] == 'a'
def test_generator():
for data_list in data:
yield check_data_list, data_list
if __name__ == '__main__':
suite = nose.suite.LazySuite(tests=test_generator())
nose.run(suite=suite)
然而,這失敗
Traceback (most recent call last):
File "test-with-nose.py", line 43, in <module>
nose.run(suite=suite)
File "/usr/local/lib/python3.5/dist-packages/nose/core.py", line 301, in run
return TestProgram(*arg, **kw).success
File "/usr/local/lib/python3.5/dist-packages/nose/core.py", line 121, in __init__
**extra_args)
File "/usr/lib/python3.5/unittest/main.py", line 94, in __init__
self.runTests()
File "/usr/local/lib/python3.5/dist-packages/nose/core.py", line 207, in runTests
result = self.testRunner.run(self.test)
File "/usr/local/lib/python3.5/dist-packages/nose/core.py", line 62, in run
test(result)
File "/usr/local/lib/python3.5/dist-packages/nose/suite.py", line 178, in __call__
return self.run(*arg, **kw)
File "/usr/local/lib/python3.5/dist-packages/nose/suite.py", line 225, in run
test(orig)
File "/usr/lib/python3.5/unittest/suite.py", line 84, in __call__
return self.run(*args, **kwds)
File "/usr/local/lib/python3.5/dist-packages/nose/suite.py", line 76, in run
test(result)
TypeError: 'tuple' object is not callable
什麼是用於創建應該看起來像LazySuite
類的實例的生成器嗎?