classification
Title: Fix tests to work with -OO
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.2, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: r.david.murray Nosy List: brian.curtin, collinwinter, jyasskin, pitrou, r.david.murray, rnk
Priority: normal Keywords: easy, patch

Created on 2009-06-16 17:25 by collinwinter, last changed 2010-02-24 02:13 by r.david.murray. This issue is now closed.

Files
File name Uploaded Description Edit
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 (6)
msg89434 - (view) Author: Collin Winter (collinwinter) * (Python committer) 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) * (Python committer) 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) * (Python committer) 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.
msg99885 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-02-23 00:30
Applied a slightly cleaned up (with help from Brian and Matias Torchinsky at the sprint) version of Brian's patch in r78351.  Leaving open until merged to py3k.
msg99993 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-02-24 01:48
Committed to py3k in r78400.  Had to add the make_request_and_skipIf decorator to test_xmplrc as well.
msg99995 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-02-24 02:13
Benjamin pointed out that the primary copy of lib2to3 is not trunk, so I backed out the change to that package.
History
Date User Action Args
2010-02-24 02:13:33r.david.murraysetmessages: + msg99995
2010-02-24 01:48:32r.david.murraysetstatus: open -> closed
priority: normal
messages: + msg99993

versions: + Python 3.2
2010-02-23 00:30:54r.david.murraysetnosy: + r.david.murray
messages: + msg99885

assignee: r.david.murray
resolution: fixed
stage: patch review -> resolved
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