unittest vs py.test?

Scott David Daniels Scott.Daniels at Acm.Org
Sun Apr 3 20:58:23 EDT 2005


Paul Rubin wrote:
> "Terry Reedy" <tjreedy at udel.edu> writes:
> 
>>>But assert statements vanish when you turn on the optimizer.  If
>>>you're going to run your application with the optimizer turned on, I
>>>certainly hope you run your regression tests with the optimizer on.
>>
>>I don't see why you think so.  Assertion statements in the test code make 
>>it harder, not easier for the test to pass.  Ditto, I believe, for any in 
>>the run code, if indeed there are any.
> 
> 
> If the unit tests are expressed as assert statements, and the assert
> statements get optimized away, then running the unit tests on the
> optimized code can obviously never find any test failures.

Any code depending upon __debug__ being 0 won't be tested.  Sometimes
test structures update values as a side-effect of tracking the debugging
state.  Not massively likely, but it makes for a scary environment when
your tests cannot be run on a non-debug version.

--Scott David Daniels
Scott.Daniels at Acm.Org



More information about the Python-list mailing list