From b1a9f2772ba21f268a8164908714e5a106be50d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Fri, 20 Jul 2007 07:13:39 +0000 Subject: [PATCH] Fix test_doctest: drop u prefixes; explicitly declare encoding as latin-1 if we want it to fail. --- Lib/test/test_doctest.py | 24 ++++++++++++------------ Lib/test/test_doctest4.txt | 10 ++-------- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/Lib/test/test_doctest.py b/Lib/test/test_doctest.py index 5730a59dd67..53073958d81 100644 --- a/Lib/test/test_doctest.py +++ b/Lib/test/test_doctest.py @@ -1898,7 +1898,7 @@ def test_DocFileSuite(): ... 'test_doctest2.txt', ... 'test_doctest4.txt') >>> suite.run(unittest.TestResult()) - + The test files are looked for in the directory containing the calling module. A package keyword argument can be provided to @@ -1910,7 +1910,7 @@ def test_DocFileSuite(): ... 'test_doctest4.txt', ... package='test') >>> suite.run(unittest.TestResult()) - + '/' should be used as a path separator. It will be converted to a native separator at run time: @@ -1958,7 +1958,7 @@ def test_DocFileSuite(): ... 'test_doctest4.txt', ... globs={'favorite_color': 'blue'}) >>> suite.run(unittest.TestResult()) - + In this case, we supplied a missing favorite color. You can provide doctest options: @@ -1969,7 +1969,7 @@ def test_DocFileSuite(): ... optionflags=doctest.DONT_ACCEPT_BLANKLINE, ... globs={'favorite_color': 'blue'}) >>> suite.run(unittest.TestResult()) - + And, you can provide setUp and tearDown functions: @@ -1990,7 +1990,7 @@ def test_DocFileSuite(): ... 'test_doctest4.txt', ... setUp=setUp, tearDown=tearDown) >>> suite.run(unittest.TestResult()) - + But the tearDown restores sanity: @@ -2245,26 +2245,26 @@ If the tests contain non-ASCII characters, the tests might fail, since it's unknown which encoding is used. The encoding can be specified using the optional keyword argument `encoding`: - >>> doctest.testfile('test_doctest4.txt') # doctest: +ELLIPSIS + >>> doctest.testfile('test_doctest4.txt', encoding='latin-1') # doctest: +ELLIPSIS ********************************************************************** File "...", line 7, in test_doctest4.txt Failed example: - u'...' + '...' Expected: - u'f\xf6\xf6' + 'f\xf6\xf6' Got: - u'f\xc3\xb6\xc3\xb6' + 'f\xc3\xb6\xc3\xb6' ********************************************************************** ... ********************************************************************** 1 items had failures: - 2 of 4 in test_doctest4.txt + 2 of 2 in test_doctest4.txt ***Test Failed*** 2 failures. - (2, 4) + (2, 2) >>> doctest.master = None # Reset master. >>> doctest.testfile('test_doctest4.txt', encoding='utf-8') - (0, 4) + (0, 2) >>> doctest.master = None # Reset master. """ diff --git a/Lib/test/test_doctest4.txt b/Lib/test/test_doctest4.txt index a219d16a6ea..0428e6f9632 100644 --- a/Lib/test/test_doctest4.txt +++ b/Lib/test/test_doctest4.txt @@ -4,14 +4,8 @@ This file is encoded using UTF-8. In order to get this test to pass, we have to manually specify the encoding. - >>> u'föö' - u'f\xf6\xf6' - - >>> u'bąr' - u'b\u0105r' - >>> 'föö' - 'f\xc3\xb6\xc3\xb6' + 'f\xf6\xf6' >>> 'bąr' - 'b\xc4\x85r' + 'b\u0105r'