classification
Title: Fix tests to work with -OO
Type: behavior Stage: patch review
Components: Tests Versions: Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: brian.curtin, collinwinter, jyasskin, pitrou, rnk (5)
Priority: Keywords easy, patch

Created on 2009-06-16 17:25 by collinwinter, last changed 2009-11-04 18:15 by brian.curtin.

Files
File name Uploaded Description Edit Remove
oo_tests.patch collinwinter, 2009-06-16 17:25 Patch against trunk, r73446
issue6292_20091104_v1.patch brian.curtin, 2009-11-04 18:15 Patch against trunk, r76107
Messages (3)
msg89434 - (view) Author: Collin Winter (collinwinter) Date: 2009-06-16 17:25
The attached patch fixes a number of tests to work when -OO is given to 
Python. The majority of these tests are docstring-related, either doctests 
or making assertions about __doc__, with a handful of tests testing that 
assert statements will trigger and another handful of distutils tests that 
are looking for .pyc files.

With this applied, PYTHONOPTIMIZE=2 ./python.exe -OO Lib/test/regrtest.py 
now passes for trunk.
msg89439 - (view) Author: Antoine Pitrou (pitrou) Date: 2009-06-16 22:25
Rather than silently skipping stuff or writing to stderr, the patch
should, as much as possible, use the new test-skipping API in unittest.
Perhaps DocTestSuite could centralize some of the effort by inspecting
sys.flags and skipping accordingly (but users may also set __doc__
manually).
msg94897 - (view) Author: Brian Curtin (brian.curtin) Date: 2009-11-04 18:15
I've attached a patch against trunk (r76107) which I think implements
more of what Antoine is looking for. It builds on Collin's patch but
uses unittest.skipIf to skip tests which shouldn't be run with -OO. It
also checks sys.flags.optimize in DocTestSuite and returns a suite with
a single skipped test as a placeholder in the case that -OO is used.

One thing that isn't really clean is that test_docxmlrpc has two skipped
tests and requires work to be done in the tearDown method after those
methods are skipped. Since setUp gets called even when the test will be
skipped, the server is started and blocking on getting a request, so I
just figure out if the test was skipped and do a request for it. Maybe
that's acceptable, I'm not sure. If anyone has a better way to figure
get around that, I'm all ears.

For comparison's sake, regrtest with -OO on r76107 results in 297 OK and
17 failed, and without optimize it results in 311/2. The patch results
in 311 OK and 2 failed for runs of regrtest both optimized and not, and
you can see the improvements more clearly when running the module-level
tests which were modified.
History
Date User Action Args
2009-11-04 18:15:51brian.curtinsetfiles: + issue6292_20091104_v1.patch
nosy: + brian.curtin
messages: + msg94897

2009-06-16 22:25:37pitrousetnosy: + pitrou
messages: + msg89439
2009-06-16 17:25:54collinwintercreate