homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Doctest gets line numbers wrongs with in name
Type: Stage: resolved
Components: Versions: Python 2.7
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: belopolsky, iritkatriel, ncoghlan, r.david.murray
Priority: normal Keywords:

Created on 2008年12月14日 08:21 by ncoghlan, last changed 2022年04月11日 14:56 by admin. This issue is now closed.

Messages (6)
msg77777 - (view) Author: Alyssa Coghlan (ncoghlan) * (Python committer) Date: 2008年12月14日 08:21
When writing the unit tests for running doctests from inside a zipfile,
I initially had "<anon>" as the name being passed to the
doctest.DocTestFinder.find method.
With that name, the line numbers coming back for all of the examples
were being incremented by 1 beyond what test_doctest expected (and hence
my tests were failing).
Changing the name to "anon" eliminated the errors. (Both "<anon" and
"anon>" also failed in the same fashion as "<anon>")
I suspect there may be a problem with __LINECACHE_FILENAME_RE when "<"
or ">" are embedded in the name used for the doctest execution.
msg112135 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010年07月31日 11:30
@Nick: could you provide a patch that addresses this issue?
msg112153 - (view) Author: Alyssa Coghlan (ncoghlan) * (Python committer) Date: 2010年07月31日 14:45
On Sat, Jul 31, 2010 at 9:30 PM, Mark Lawrence <report@bugs.python.org> wrote:
>
> Mark Lawrence <breamoreboy@yahoo.co.uk> added the comment:
>
> @Nick: could you provide a patch that addresses this issue?
Probably, but the "don't do that" work around is trivial enough that
my own motivation to fix it is really low (otherwise I would have
fixed it by now).
It's still a genuine bug though. Since my original post isn't all that
helpful in reproducing it, I'll provide some more details for anyone
else that wants to tackle it.
To reproduce it, edit Lib/test/test_zipimport_support.py to pass
"<anon>" instead of name as the second argument to the finder.find
call inside _run_object_doctest(). Running "python -m test.regrtest
test_zipimport_support" will fail (with 6 of 33 doctests failing as of
2.7)
Then pass "anon" (no angle brackets) to see that the reported doctest
errors are different (1 of 19 reported as failing in 2.7) and, unlike
the errors with "<anon>" the error in this latter case is directly
attributable to having the wrong module name in the pdb output.
(Note: regrtest's "-v" option is actually more confusing than helpful
in debugging this test case due to the sheer amount of output it
generates from the doctest tests themselves)
msg132705 - (view) Author: Alyssa Coghlan (ncoghlan) * (Python committer) Date: 2011年03月31日 21:29
Note that this appears to have been fixed already in the 3.x series (I haven't investigated the differences to see what makes this a 2.x only problem)
msg132725 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2011年04月01日 01:20
I have a vague memory of changing some code, in linecache I think, that involved anonymous names. I might have fixed it by accident.
msg381614 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2020年11月22日 12:45
I tested on 3.10 (macos) and can confirm that it is fixed. 
Details: I changed _run_object_doctest as Nick explained, and made it display the output of the finder.find() call - the line number was the same with and without the <>s.
History
Date User Action Args
2022年04月11日 14:56:42adminsetgithub: 48907
2020年11月22日 12:45:37iritkatrielsetstatus: open -> closed

nosy: + iritkatriel
messages: + msg381614

resolution: out of date
stage: resolved
2014年02月03日 19:16:57BreamoreBoysetnosy: - BreamoreBoy
2011年04月01日 01:20:21r.david.murraysetnosy: + r.david.murray
messages: + msg132725
2011年03月31日 21:29:33ncoghlansetmessages: + msg132705
versions: + Python 2.7
2010年07月31日 14:45:29ncoghlansetmessages: + msg112153
2010年07月31日 11:30:46BreamoreBoysetnosy: + BreamoreBoy
messages: + msg112135
2008年12月15日 02:31:59belopolskysetnosy: + belopolsky
2008年12月14日 08:21:25ncoghlancreate

AltStyle によって変換されたページ (->オリジナル) /