[TIP] Generator methods and nose: a bit lost...

jason pellerin jpellerin at gmail.com
Tue Apr 21 15:12:25 PDT 2009

On Tue, Apr 21, 2009 at 5:53 PM, Fernando Perez <fperez.net at gmail.com> wrote:
> Hi all,
> I've been reading the nose docs about generator methods, and as far as
> I can make out from the information provided, there's nothing special
> required of them in the signature or anything else.  So I'm stumped as
> to why this particular bit of code doesn't work:

The problem is with what you're yielding as the test callable. The
"functions" in nose.tools are actually bound methods of a singleton
unittest.TestCase. You *can't* safely yield them directly as test
callables, because to nose they look like what they are, and therefore
nose tries to run the test case that contains them.

Your example will work fine if you define your own assert_true:

def assert_true(arg):

and yield that instead.


More information about the testing-in-python mailing list