According to nosetest's API documentation, there is a LazySuite()
class which is
class nose.suite.LazySuite(tests=())
A suite that may use a generator as its list of tests
However, I could not find any example how this test generator is supposed to look like. I tried to write one the way that one would use when yielding test cases to nosetest's test discovery and pass it to the LazySuite
constructor as follows:
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)
This, however, fails with
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
What is the generator for creating an instance of the LazySuite
class supposed to look like instead?