[Zope-Coders] -O considered useful

Tim Peters tim@zope.com
Tue, 23 Oct 2001 19:01:45 -0400


[Jeffrey P Shell]
> 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?

Running with -O can easily trigger new program logic errors (for example, a
variable initialized only in an "if __debug__:" block).  So, if you're going
to release code intended to be run using -O, you're not testing it as it's
intended to be used unless you test it with -O too.  Testing code in ways
it's not intended to be used is the odder exercise of the two <wink>.

For this reason, all uses of "assert" were purged from Python's test suite
some time ago, and, yes, since then, some tests have failed only under -O,
some only without -O, and some both ways.  We're happy to find bugs any way
we can get them, and running a test suite is the easiest way there is.