[py-dev] py.test generative tests unexpected behavior

Carl Friedrich Bolz cfbolz at gmx.de
Mon Dec 17 16:25:36 CET 2007


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


More information about the py-dev mailing list