classification
Title: undefined name in doctest.py
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.2, Python 3.3, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: r.david.murray Nosy List: belopolsky, brian.curtin, georg.brandl, maker, michael.foord, python-dev, r.david.murray
Priority: normal Keywords: patch

Created on 2011-08-16 07:18 by georg.brandl, last changed 2012-03-21 19:11 by r.david.murray. This issue is now closed.

Files
File name Uploaded Description Edit
t.py georg.brandl, 2011-08-16 07:18
doctest.patch r.david.murray, 2012-03-17 19:44
doctest.patch r.david.murray, 2012-03-17 19:59
Messages (7)
msg142165 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2011-08-16 07:18
doctest.py, line 2274 (in 2.7):

    def shortDescription(self):
        return "Skipping tests from %s" % module.__name__

"module" is not defined here. Assigning to David since he last changed this line. Test script attached.
msg142339 - (view) Author: Michele OrrĂ¹ (maker) * Date: 2011-08-18 15:25
It is possible to retrieve the current module using _normalize_module(None), or instead use the test name (dt_test.name) just like in DocTestCase.shortDescription.

Since there is no doc about it, IMHO we should use unittest's standard as guideline, which is: 
shortDescription()
 Returns a description of the test, or None if no description has been   
 provided. The default implementation of this method returns the first 
 line of the test method’s docstring, if available, or None.
(i.e., DocTestCase._dt_test.name)

What's your opinion?
msg156194 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-03-17 19:44
The patch was actually by Brian Curtin, before he got commit privs :).

Attached is a fix.  

I don't know what t.py has to do with the issue, though.  I'm experimenting to see if I can trigger the bug before I apply the fix.
msg156197 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-03-17 19:59
OK, ./python -OO -m test test_json will trigger it.

Updated fix attached.  I'm not completely happy with it, though, since it prints the 'skipping test from module XXX' twice, and I don't know why (some unittest thing I'm not getting right, doubtless).
msg156199 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-03-17 20:02
Oh, in case anyone is wondering, the fix for -OO test runs was originally made because the unladen swallow folks ran the test suite that way.  (I think someone else wanted it too, but I don't remember who).  It's broken again, so I doubt anyone is actually doing this now, and if we want to keep supporting this use case (maybe we don't), then we should have a buildbot running the test suite with -OO.  I might be able to set one up at some point.
msg156505 - (view) Author: Roundup Robot (python-dev) Date: 2012-03-21 19:02
New changeset 64f1b8ad9214 by R David Murray in branch '3.2':
#12757: Make doctest skipping in -OO mode work with unittest/regrtest -v
http://hg.python.org/cpython/rev/64f1b8ad9214

New changeset ff7957aa01a1 by R David Murray in branch 'default':
Merge #12757: Make doctest skipping in -OO mode work with unittest/regrtest -v
http://hg.python.org/cpython/rev/ff7957aa01a1

New changeset c50db3d06116 by R David Murray in branch '2.7':
#12757: Make doctest skipping in -OO mode work with unittest/regrtest -v
http://hg.python.org/cpython/rev/c50db3d06116
msg156506 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-03-21 19:11
Since nobody really cares about this issue :), I went ahead and applied the patch that at least avoids the tracebacks.  Someone can open a new bug about the duplicated message if they really care.
History
Date User Action Args
2012-03-21 19:11:05r.david.murraysetstatus: open -> closed
type: behavior
messages: + msg156506

resolution: fixed
stage: test needed -> resolved
2012-03-21 19:02:43python-devsetnosy: + python-dev
messages: + msg156505
2012-03-17 20:02:20r.david.murraysetmessages: + msg156199
2012-03-17 19:59:51r.david.murraysetfiles: + doctest.patch
nosy: + michael.foord
messages: + msg156197

2012-03-17 19:47:08r.david.murraysetnosy: + brian.curtin
2012-03-17 19:44:52r.david.murraysetfiles: + doctest.patch
keywords: + patch
messages: + msg156194

stage: needs patch -> test needed
2011-08-18 15:25:18makersetnosy: + maker
messages: + msg142339
2011-08-17 11:42:18belopolskysetnosy: + belopolsky
2011-08-16 07:18:06georg.brandlcreate