Class generator test name

29 views
Skip to first unread message

Brandon

unread,
Sep 25, 2008, 3:47:59 PM9/25/08
to nose-users
Hi all,

I have a method inside a class that is a generator. The yielded
function is a method in the class. Python does not allow me to set
the .description attribute or the .__doc__ attribute when it runs...is
there another way to set the test name for the class function?

Thanks,

Brandon

Kumar McMillan

unread,
Nov 2, 2008, 12:00:28 PM11/2/08
to nose-...@googlegroups.com

nose also looks for __name__, however, you quickly run into scoping
issues if you try to set that in a generator. Nose will however use
the arguments sent to your method as part of the name which you can
use to make more readable tests. For example:

class TestA:
def _test(self, type):
pass

def test_many(self):
for t in ['foo','bar','fooz']:
yield (self._test,t)

$ nosetests -v
test_a.TestA.test_many('foo',) ... ok
test_a.TestA.test_many('bar',) ... ok
test_a.TestA.test_many('fooz',) ... ok

----------------------------------------------------------------------
Ran 3 tests in 0.006s

OK

Reply all
Reply to author
Forward
0 new messages