[py-dev] Failing to manage test state of a module with py.test
Pierre Rouleau
prouleau001 at gmail.com
Thu Nov 16 22:43:30 CET 2006
On 11/16/06, Maciek Fijalkowski <fijal at genesilico.pl> wrote:
> Pierre Rouleau wrote:
>
> >
> > I forgot to mention that the setup_module() was setting the value of
> > knownValues after declaring it global. I though that it would then be
> > available to all test functions (as is the case with nose), but it's
> > not.
> >
> > The setup_module I have looks like this:
> >
> > def setup_module(roman):
> > print 'SETTING UP........................'
> >
> > global knownValues
> > knownValues = ( (1, 'I'),
> > (2, 'II'),
> > Note that nose is able to recover the global variable and the test
> > succeeds in nosetests. py.test does not seem able to do it. It's not
> > that I absolutely want to use global variables, but I wanted to checks
> > the module setup mechanism.
> >
>
> Of course tha you just write:
>
> def setup_module(mod):
> mod.some_global_value = whatever_you_like
>
> :-) It's of course better, because explicit is better than implicit (you
> avoid exporting all variables used in setup_)
>
But of course!!! what was I thinking! ;) Now I see why there is a
module argument!!
Thanks!
More information about the Pytest-dev
mailing list