New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"python -m doctest" results in FAIL: Doctest: __main__.DebugRunner #51625
Comments
Running on Debian Lenny, with Python 3.1. ~ $ python3 --version Traceback (most recent call last):
File "/usr/lib/python3.1/doctest.py", line 2096, in runTest
raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for __main__.DebugRunner
File "/usr/lib/python3.1/doctest.py", line 1644, in DebugRunner
----------------------------------------------------------------------
File "/usr/lib/python3.1/doctest.py", line 1712, in __main__.DebugRunner
Failed example:
runner.run(test)
Expected:
Traceback (most recent call last):
...
doctest.UnexpectedException: <DocTest foo from foo.py:0 (2 examples)>
Got:
Traceback (most recent call last):
File "/usr/lib/python3.1/doctest.py", line 1243, in __run
compileflags, 1), test.globs)
File "<doctest __main__.DebugRunner[15]>", line 1, in <module>
runner.run(test)
File "/usr/lib/python3.1/doctest.py", line 1736, in run
r = DocTestRunner.run(self, test, compileflags, out, False)
File "/usr/lib/python3.1/doctest.py", line 1375, in run
return self.__run(test, compileflags, out)
File "/usr/lib/python3.1/doctest.py", line 1296, in __run
exception)
File "/usr/lib/python3.1/doctest.py", line 1742, in
report_unexpected_exception
raise UnexpectedException(test, example, exc_info)
UnexpectedException: <DocTest foo from foo.py:0 (2 examples)> Ran 15 tests in 0.015s FAILED (failures=1) |
Apparently this was introduced with r51625 : r51625 | guido.van.rossum | 2006-08-26 16:37:44 -0400 (Sat, 26 Aug 2006) Inspired by SF patch bpo-860326, make the exception formatting by ------------------------------------------------------------------------ When doctest is imported as __main__, traceback does not prepend This is rather inelegant and a better solution would probably be to use |
python -m doctest does accept file arguments. Running the self-test is python -m doctest Lib/doctest.py passes. So perhaps we should just remove the default and instead issue an error |
I am ok with the proposal of removing the current "selftest" default And thank you for the tip.
;) |
Patch proposed. |
Patch could be applied to Python 2.6 and trunk too. |
Minor update: replaced '{}' by '{0}' for compatibility with 2.6. Ready for review and merge. |
The patch results in this type of usage message: usage: /home/rdmurray/python/trunk/Lib/doctest.py [-v] file ... which while technically correct isn't the way I called it. It would be |
Variant which gives different usage messages: ~ $ ./python -m doctest ~ $ ./python Lib/doctest.py |
I has already adjusted the patch, in a slightly different fashion, but |
The bug doesn't exist on 2.6, so I'm not backporting. Ported to py3k in |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: