Issue1729305
Created on 2007-06-01 05:16 by nnorwitz, last changed 2009-10-11 16:09 by ezio.melotti.
| File name |
Uploaded |
Description |
Edit |
Remove |
|
doctest.patch
|
mbeachy,
2008-02-24 13:10
|
doctest patch that keeps track of encoding |
|
|
|
test_doctest.patch
|
mbeachy,
2008-02-24 13:12
|
test for the bug |
|
|
|
doctestfail.txt
|
ezio.melotti,
2009-10-11 16:09
|
traceback of the test failure |
|
|
|
msg32174 - (view) |
Author: Neal Norwitz (nnorwitz) |
Date: 2007-06-01 05:16 |
|
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)
|
|
msg62896 - (view) |
Author: Mike Beachy (mbeachy) |
Date: 2008-02-24 13:10 |
|
The basic issue here is that running in verbose mode echoes back the
expected values from the file, so the results from non-ascii doctest
files must be encoded before printing.
It looks to me like the DocTestRunner class must grow an '_encoding'
attribute to keep track of how to encode any verbose output. I've
attached a patch that does this.
Happy post bug day!
Mike
|
|
msg62897 - (view) |
Author: Mike Beachy (mbeachy) |
Date: 2008-02-24 13:12 |
|
Here's a patch for test_doctest.py that checks the problem has been fixed.
|
|
msg93861 - (view) |
Author: Ezio Melotti (ezio.melotti) |
Date: 2009-10-11 16:09 |
|
This test still fail on Win7 with Py2.6.3rc1 in verbose mode, it works
fine in normal mode.
I attached a file with the traceback.
|
|
| Date |
User |
Action |
Args |
| 2009-10-11 16:09:44 | ezio.melotti | set | files:
+ doctestfail.txt versions:
+ Python 2.6, - Python 2.5 nosy:
+ ezio.melotti
messages:
+ msg93861
|
| 2008-02-24 13:12:37 | mbeachy | set | files:
+ test_doctest.patch messages:
+ msg62897 |
| 2008-02-24 13:10:51 | mbeachy | set | files:
+ doctest.patch keywords:
+ patch messages:
+ msg62896 nosy:
+ mbeachy |
| 2007-06-01 05:16:47 | nnorwitz | create | |
|