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

Fernando Perez fperez.net at gmail.com
Tue Apr 21 15:20:10 PDT 2009


Hi Jason,

On Tue, Apr 21, 2009 at 3:12 PM, jason pellerin <jpellerin at gmail.com> wrote:

> Your example will work fine if you define your own assert_true:
>
> def assert_true(arg):
>    nt.assert_true(arg)
>
> and yield that instead.

Many thanks, that's all I need for now and it clarifies the problem.
If I may suggest, it would be great to include a note on this matter
in the docs, as the error was a bit mysterious.

I also wonder if you'd want to consider making all of the
nose.tools.assert* functions be wrapped as above by default, so that
users can generically rely on nt.assert* for all their assertion
needs, regardless of whether they are writing code in a function or in
a class.  It would make the nose-based workflow smoother, since it
seems that right now one needs to know a bit of internals arcana when
refactoring from plain functions to classes.

I tend to favor (and that's one of the many reasons I'm such a huge
fan of nose) writing my tests in as simple a manner as possible, so I
start with functions.  Only when I realize that I can actually
*benefit* from inheritance do I refactor them into classes (as opposed
to being forced into it like unittest does).  So I would love it if
the mental overhead of that refactoring were lowered even further, by
not having to worry about this kind of detail.

In any case, thanks again both for your help and the fantastic nose tool :)

Cheers,

f



More information about the testing-in-python mailing list