[TIP] Generator methods and nose: a bit lost...
fperez.net at gmail.com
Tue Apr 21 15:32:01 PDT 2009
On Tue, Apr 21, 2009 at 3:20 PM, Fernando Perez <fperez.net at gmail.com> wrote:
> 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.
For the sake of completeness, here's the code to do this:
# Make a bunch of nose.tools assert wrappers that can be used in test
nose_asserts = [a for a in dir(nt) if a.startswith('assert')]
tpl = """
for a in nose_asserts:
exec tpl % dict(name=a)
# I'll just use that now in my own codes, since it frees me from
having to think :)
More information about the testing-in-python