summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_doctest.py
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2010-02-27 14:37:21 (GMT)
committerFlorent Xicluna <florent.xicluna@gmail.com>2010-02-27 14:37:21 (GMT)
commite94b221d5ed5d1f5efc6087623dbbe2916b478bc (patch)
tree0bacbe188fe5d48e6d4b7620cc0a1423d8502644 /Lib/test/test_doctest.py
parent8f1c275daafaa57e5e467d759d28ae4875c9e16f (diff)
downloadcpython-e94b221d5ed5d1f5efc6087623dbbe2916b478bc.zip
cpython-e94b221d5ed5d1f5efc6087623dbbe2916b478bc.tar.gz
cpython-e94b221d5ed5d1f5efc6087623dbbe2916b478bc.tar.bz2
Merged revisions 78493 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ................ r78493 | florent.xicluna | 2010-02-27 15:21:57 +0100 (sam, 27 fév 2010) | 11 lines For 3.x, the "backslashreplace" error handling is plugged on the "write" method. Recorded merge of revisions 78488 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r78488 | florent.xicluna | 2010-02-27 14:31:23 +0100 (sam, 27 fév 2010) | 2 lines Issue #1729305: Fix doctest to handle encode error with "backslashreplace". It fixes #7667 too. ........ ................
Diffstat (limited to 'Lib/test/test_doctest.py')
-rw-r--r--Lib/test/test_doctest.py31
1 files changed, 30 insertions, 1 deletions
diff --git a/Lib/test/test_doctest.py b/Lib/test/test_doctest.py
index 8dcc8a4..c9b1b85 100644
--- a/Lib/test/test_doctest.py
+++ b/Lib/test/test_doctest.py
@@ -2147,6 +2147,13 @@ doctest examples in a given file. In its simple invokation, it is
called with the name of a file, which is taken to be relative to the
calling module. The return value is (#failures, #tests).
+We don't want `-v` in sys.argv for these tests.
+
+ >>> save_argv = sys.argv
+ >>> if '-v' in sys.argv:
+ ... sys.argv = [arg for arg in save_argv if arg != '-v']
+
+
>>> doctest.testfile('test_doctest.txt') # doctest: +ELLIPSIS
**********************************************************************
File "...", line 6, in test_doctest.txt
@@ -2286,6 +2293,28 @@ using the optional keyword argument `encoding`:
>>> doctest.testfile('test_doctest4.txt', encoding='utf-8')
TestResults(failed=0, attempted=2)
>>> doctest.master = None # Reset master.
+
+Test the verbose output:
+
+ >>> doctest.testfile('test_doctest4.txt', encoding='utf-8', verbose=True)
+ Trying:
+ 'föö'
+ Expecting:
+ 'f\xf6\xf6'
+ ok
+ Trying:
+ 'bąr'
+ Expecting:
+ 'b\u0105r'
+ ok
+ 1 items passed all tests:
+ 2 tests in test_doctest4.txt
+ 2 tests in 1 items.
+ 2 passed and 0 failed.
+ Test passed.
+ TestResults(failed=0, attempted=2)
+ >>> doctest.master = None # Reset master.
+ >>> sys.argv = save_argv
"""
def test_testmod(): r"""
@@ -2295,7 +2324,7 @@ fail with a UnicodeDecodeError because doctest tried to read the "source" lines
out of the binary module.
>>> import unicodedata
- >>> doctest.testmod(unicodedata)
+ >>> doctest.testmod(unicodedata, verbose=False)
TestResults(failed=0, attempted=0)
"""