New submission from Daniel Nouri:
doctest.DocTestParser._EXCEPTION_RE does not allow for output before the
actual traceback.
Attached is a simple test that demonstrates the problem. This patch
fixes it:
--- /usr/lib/python2.5/doctest.py 2007-10-22 21:45:21.000000000 +0200
+++ /home/daniel/tmp/doctest.py 2007-10-22 22:19:12.000000000 +0200
@@ -513,7 +513,7 @@
_EXCEPTION_RE = re.compile(r"""
# Grab the traceback header. Different versions of Python have
# said different things on the first traceback line.
- ^(?P<hdr> Traceback\ \(
+ .*^(?P<hdr> Traceback\ \(
(?: most\ recent\ call\ last
| innermost\ last
) \) :
_EXCEPTION_RE = re.compile(r"""
# Grab the traceback header. Different versions of Python have
# said different things on the first traceback line.
^(?P<hdr> Traceback\ \(
(?: most\ recent\ call\ last
| innermost\ last
) \) :
)
\s* $ # toss trailing whitespace on the header.
(?P<stack> .*?) # don't blink: absorb stuff until...
^ (?P<msg> \w+ .*) # a line *starts* with alphanum.
""", re.VERBOSE | re.MULTILINE | re.DOTALL)
----------
components: Library (Lib)
files: doctest-bug.py
messages: 56655
nosy: nouri
severity: normal
status: open
title: doctest EXCEPTION_RE can't handle preceding output
versions: Python 2.5
Added file: http://bugs.python.org/file8591/doctest-bug.py
__________________________________
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1312>
__________________________________
def f():
"""
>>> f() # doctest: +ELLIPSIS
Hello, World!
Traceback (most recent call last):
...
ValueError: foo
"""
print "Hello, World!"
raise ValueError("foo")
def _test():
import doctest
doctest.testmod()
if __name__ == "__main__":
_test()
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com