[Baypiggies] test method decorators

Benjamin Sergeant bsergean at gmail.com
Fri Jun 15 15:45:35 CEST 2007

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 ?


(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.
        import wxpil
    except ImportError:
        import gtkpil
    except ImportError:

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

More information about the Baypiggies mailing list