[py-dev] Does each test method get called with a new instance?

Roy Smith roy at panix.com
Tue Apr 5 15:15:09 CEST 2005


Is the control flow example at  
http://codespeak.net/py/current/doc/test.html#example-for-managing- 
state-at-module-class-and-method-level correct?  It implies that  
instance.test_42() and instance.test_23() both get called with the same  
instance.  I would have thought a new instance would be created for  
each call.

Hmmmm, a little experimenting shows that it is indeed correct.  This  
seems counter-intuitive.  I've always considered it a basic maxim of  
unit tests that each test ran in a pristine environment.  What's the  
logic here?




More information about the Pytest-dev mailing list