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
test_doctest fails when run in verbose mode #45022
Comments
This happens on trunk, p3yk branch and 2.5. Trying:
doctest.testfile('test_doctest4.txt', encoding='utf-8')
Expecting:
(0, 4)
test test_doctest crashed -- <type 'exceptions.UnicodeEncodeError'>: 'ascii' codec can't encode characters in position 301-302: ordinal not in range(128)
Traceback (most recent call last):
File "./Lib/test/regrtest.py", line 557, in runtest_inner
indirect_test()
File "/home/neal/python/dev/r25/Lib/test/test_doctest.py", line 2402, in test_main
test_support.run_doctest(test_doctest, verbosity=True)
File "/home/neal/python/dev/r25/Lib/test/test_support.py", line 467, in run_doctest
f, t = doctest.testmod(module, verbose=verbosity)
File "/home/neal/python/dev/r25/Lib/doctest.py", line 1799, in testmod
runner.run(test)
File "/home/neal/python/dev/r25/Lib/doctest.py", line 1345, in run
return self.__run(test, compileflags, out)
File "/home/neal/python/dev/r25/Lib/doctest.py", line 1261, in __run
self.report_failure(out, test, example, got)
File "/home/neal/python/dev/r25/Lib/doctest.py", line 1125, in report_failure
self._checker.output_difference(example, got, self.optionflags))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 301-302: ordinal not in range(128) |
The basic issue here is that running in verbose mode echoes back the It looks to me like the DocTestRunner class must grow an '_encoding' Happy post bug day! |
Here's a patch for test_doctest.py that checks the problem has been fixed. |
This test still fail on Win7 with Py2.6.3rc1 in verbose mode, it works |
It still occurs on trunk. test test_doctest crashed -- <type 'exceptions.UnicodeEncodeError'>: |
The patch did not work with latest trunk. Here is an updated version of the patch. Patch tested with different commands: |
And for Python 3. (Slightly different) |
This patch is simpler, and it fixes bpo-7667 too. |
For Py3k, it is enough to "backslashreplace" the errors on "write". |
Fixed in r78488 and r78493. |
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: