[Baypiggies] test method decorators
Shannon -jj Behrens
jjinux at gmail.com
Fri Jun 15 22:09:43 CEST 2007
Thanks for the talk, Collin!
Somewhat orthogonal:
By the way, to answer someone's related question yesterday, Nose knows
how to do module-level setup and tear down. I think it's as easy as
writing a "setup" and a "teardown" method at the module level.
Naturally, class-level is also possible.
Happy Hacking!
-jj
On 6/15/07, Benjamin Sergeant <bsergean at gmail.com> wrote:
> One other decorator idea, close to the platform one, would be a module specific.
> RIght now in my test I do it in my main runner script, trying to
> import module specific tests, and removing them from the test modules
> if the import fail.
>
> Could we have a TestCase decorator level to do that (that might not
> work since the module are imported in the first line of the test case
> script) ?
> Is there a better way to do that ?
> Would it be a TestRunner decorator ?
>
> Benjamin.
>
> <<<
> (from http://pytof.googlecode.com/svn/trunk/test/test.py)
> def getDefaultTestModules():
> defaultTestModules = [os.path.splitext(i)[0] for i in glob('*_test.py')]
> # Remove tests that require non-installed dependency.
> try:
> import wxpil
> except ImportError:
> defaultTestModules.remove('wxpil_test')
> try:
> import gtkpil
> except ImportError:
> defaultTestModules.remove('gtkpil_test')
> >>>
>
> On 6/15/07, Kelly Yancey <kelly at nttmcl.com> wrote:
> >
> > A couple of people asked me after the meeting to post my test method
> > decorators for implementing TODO and platform-specific test annotations
> > using the unittest module (they should work for nose too). I just put
> > them up on my blog at:
> > http://kbyanc.blogspot.com/2007/06/pythons-unittest-module-aint-that-bad.html
> >
> > I whipped them up during the meeting, so they are a little rough
> > around the edges and only lightly tested, but I think they express the
> > idea that unittest can do composition of extensions using function
> > wrappers. Python's decorator syntax makes wrapping the test methods
> > easy on the eyes and intuitive. The only thing I am currently aware of
> > that cannot be done using decorators is implementing alternate loggers
> > (e.g. to database or to XML). The unittest module has some support for
> > replacing loggers, and Collin alluded to an XML logger that I link to in
> > my blog, but composition of loggers, as Collin mentioned in his talk, is
> > distinctly non-trivial.
> >
> > Kelly
> >
> > --
> > Kelly Yancey
> > http://kbyanc.blogspot.com/
> > _______________________________________________
> > Baypiggies mailing list
> > Baypiggies at python.org
> > To change your subscription options or unsubscribe:
> > http://mail.python.org/mailman/listinfo/baypiggies
> >
> _______________________________________________
> Baypiggies mailing list
> Baypiggies at python.org
> To change your subscription options or unsubscribe:
> http://mail.python.org/mailman/listinfo/baypiggies
>
--
http://jjinux.blogspot.com/
More information about the Baypiggies
mailing list