----- Original Message ----- From: Carl Friedrich Bolz <[EMAIL PROTECTED]> Date: Monday, December 17, 2007 8:25 am Subject: Re: [py-dev] py.test generative tests unexpected behavior
> Hi! > > j. vickroy wrote: > [snip] > > The attached file (py-test-generator-trial.py) demonstrates a > behavior I > > do not understand. > [snip] > > I don't know generative test semantics all that well, I hoped > somebody > else would answer this. However, my theory is as follows: > > py.test first collects all the results of the generator and then > runs > them all. Since your test keeps global state, the state is already > changed when the first test is run. To me this sounds like > reasonable > behavior, global state is not good in tests anyway. > > Does that make things clearer? > > Cheers, > > Carl Friedrich > _______________________________________________ > py-dev mailing list > py-dev@codespeak.net > http://codespeak.net/mailman/listinfo/py-dev > Thanks, Carl. I do understand (at least) some of the pitfalls of global state and I do *almost always* avoid using it. However, in this case, I am having difficulty seeing why it is responsible for the observed behavior. Having said that, prior to using the global *image* object, I tried to use the setup_module(module) function to define the *image* object but was unable to determine how to reference it in the test function. The global *image* object was a crude work-around. Can you offer some suggestions on how I should have proceeded given that I really do not need to create a new *image* object for each test. Thanks again, -- jv _______________________________________________ py-dev mailing list py-dev@codespeak.net http://codespeak.net/mailman/listinfo/py-dev