I'm creating tests on the fly (I must) in python to run with nosetests as below:
def my_verification_method(param):
""" description """
assert param>0, "something bad..."
def test_apps():
""" make tests on the fly """
param1 = 1
my_verification_method.__doc__ = "test with param=%i" % param1
yield my_verification_method, param1
param1 = 2
my_verification_method.__doc__ = "test with param=%i" % param1
yield my_verification_method, param1
The problem is that that nosetest prints:
make tests on the fly ... ok
make tests on the fly ... ok
which is not what I want. I want the output of nosetests say:
test with param=1 ... ok
test with param=2 ... ok
Any ideas?
Here is how to do what you want, but it will be bypassing
yield
test generation. In essence, you stuff on the fly a blankunittest.TestCase
usingpopulate()
method below:You should get:
You will need to change method name as well as doc string in order to populate your class properly.
EDIT: func_name should have
self
as an argument, since it is a class method now.