[Zope-Coders] -O considered useful
Jeffrey P Shell
jeffrey@cuemedia.com
Tue, 23 Oct 2001 09:36:20 -0600
On Monday, October 22, 2001, at 07:33 PM, Jeremy Hylton wrote:
> This reminds me:
>
> If you run with python -O, you execute slightly different code. The
> compiler optimizes away all code inside if __debug__ and all code in
> assert statements. As a result, many regression tests do nothing when
> run with python -O.
>
> We should fix our tests to use the assertXXX methods, like assertEqual
> instead of using assert statements. Note that assertEqual also
> produces a better default error message than assert x == y.
I remember seeing this debated when looking through the archives of
the PyUnit mailing list. But I always found it silly - why run the
tests optimized? Isn't testing usually a form of debugging?
I agree about using the methods when they make sense. However,
there's still a large bulk of Zope unit tests that were written
before many of those tests were available in the PyUnit that was
used. I'm sure this contributed to some habit forming as well.
jeffrey@cuemedia.com