I'm trying to create a genericized data driven test handler that I can call from my nose tests. My test file would look like:
import ScenarioHandler
def test_foo():
scenario = ScenarioHandler(__test_foo, [1, 2])
scenario.run()
def __test_foo(var):
assert var % 2 == 0, 'Odd!'
ScenarioHandler would be something like this:
class ScenarioHandler(object):
def __init__(self, test, args):
self.test = test
self.args = args
def run(self):
for arg in self.args:
yield self.test, arg
The problem I'm running in to is that I can't figure out how to bubble the generator from ScenarioHandler.run()
back up to nose. I've tried returning the generator from run()
in test_foo()
, and that was no good either. Is this even possible?