4
4
5
5
from test import support
6
6
from test .support import import_helper
7
- from test .support .pty_helper import FakeInput # used in doctests
8
7
import doctest
9
8
import functools
10
9
import os
16
15
import tempfile
17
16
import types
18
17
import contextlib
19
- import _colorize
20
18
21
19
22
20
def doctest_skip_if (condition ):
@@ -471,7 +469,7 @@ def basics(): r"""
471
469
>>> tests = finder.find(sample_func)
472
470
473
471
>>> print(tests) # doctest: +ELLIPSIS
474
- [<DocTest sample_func from test_doctest.py:38 (1 example)>]
472
+ [<DocTest sample_func from test_doctest.py:36 (1 example)>]
475
473
476
474
The exact name depends on how test_doctest was invoked, so allow for
477
475
leading path components.
@@ -893,6 +891,7 @@ def basics(): r"""
893
891
DocTestRunner is used to run DocTest test cases, and to accumulate
894
892
statistics. Here's a simple DocTest case we can use:
895
893
894
+ >>> import _colorize
896
895
>>> save_colorize = _colorize.COLORIZE
897
896
>>> _colorize.COLORIZE = False
898
897
@@ -1027,6 +1026,7 @@ def exceptions(): r"""
1027
1026
lines between the first line and the type/value may be omitted or
1028
1027
replaced with any other string:
1029
1028
1029
+ >>> import _colorize
1030
1030
>>> save_colorize = _colorize.COLORIZE
1031
1031
>>> _colorize.COLORIZE = False
1032
1032
@@ -1303,6 +1303,7 @@ def optionflags(): r"""
1303
1303
The DONT_ACCEPT_TRUE_FOR_1 flag disables matches between True/False
1304
1304
and 1/0:
1305
1305
1306
+ >>> import _colorize
1306
1307
>>> save_colorize = _colorize.COLORIZE
1307
1308
>>> _colorize.COLORIZE = False
1308
1309
@@ -1736,6 +1737,7 @@ def option_directives(): r"""
1736
1737
single example. To turn an option on for an example, follow that
1737
1738
example with a comment of the form ``# doctest: +OPTION``:
1738
1739
1740
+ >>> import _colorize
1739
1741
>>> save_colorize = _colorize.COLORIZE
1740
1742
>>> _colorize.COLORIZE = False
1741
1743
@@ -2002,6 +2004,7 @@ def test_debug(): r"""
2002
2004
2003
2005
Create some fake stdin input, to feed to the debugger:
2004
2006
2007
+ >>> from test.support.pty_helper import FakeInput
2005
2008
>>> real_stdin = sys.stdin
2006
2009
>>> sys.stdin = FakeInput(['next', 'print(x)', 'continue'])
2007
2010
@@ -2031,6 +2034,7 @@ def test_pdb_set_trace():
2031
2034
with a version that restores stdout. This is necessary for you to
2032
2035
see debugger output.
2033
2036
2037
+ >>> import _colorize
2034
2038
>>> save_colorize = _colorize.COLORIZE
2035
2039
>>> _colorize.COLORIZE = False
2036
2040
@@ -2048,6 +2052,7 @@ def test_pdb_set_trace():
2048
2052
To demonstrate this, we'll create a fake standard input that
2049
2053
captures our debugger input:
2050
2054
2055
+ >>> from test.support.pty_helper import FakeInput
2051
2056
>>> real_stdin = sys.stdin
2052
2057
>>> sys.stdin = FakeInput([
2053
2058
... 'print(x)', # print data defined by the example
@@ -2086,7 +2091,7 @@ def test_pdb_set_trace():
2086
2091
... runner.run(test)
2087
2092
... finally:
2088
2093
... sys.stdin = real_stdin
2089
- > <doctest test.test_doctest.test_doctest.test_pdb_set_trace[9 ]>(3)calls_set_trace()
2094
+ > <doctest test.test_doctest.test_doctest.test_pdb_set_trace[11 ]>(3)calls_set_trace()
2090
2095
-> import pdb; pdb.set_trace()
2091
2096
(Pdb) print(y)
2092
2097
2
@@ -2188,6 +2193,7 @@ def test_pdb_set_trace_nested():
2188
2193
>>> parser = doctest.DocTestParser()
2189
2194
>>> runner = doctest.DocTestRunner(verbose=False)
2190
2195
>>> test = parser.get_doctest(doc, globals(), "foo-bar@baz", "foo-bar@baz.py", 0)
2196
+ >>> from test.support.pty_helper import FakeInput
2191
2197
>>> real_stdin = sys.stdin
2192
2198
>>> sys.stdin = FakeInput([
2193
2199
... 'step',
@@ -2700,6 +2706,7 @@ def test_testfile(): r"""
2700
2706
2701
2707
We don't want color or `-v` in sys.argv for these tests.
2702
2708
2709
+ >>> import _colorize
2703
2710
>>> save_colorize = _colorize.COLORIZE
2704
2711
>>> _colorize.COLORIZE = False
2705
2712
@@ -3007,6 +3014,7 @@ def test_testmod(): r"""
3007
3014
def test_unicode (): """
3008
3015
Check doctest with a non-ascii filename:
3009
3016
3017
+ >>> import _colorize
3010
3018
>>> save_colorize = _colorize.COLORIZE
3011
3019
>>> _colorize.COLORIZE = False
3012
3020
@@ -3331,6 +3339,7 @@ def test_run_doctestsuite_multiple_times():
3331
3339
3332
3340
def test_exception_with_note (note ):
3333
3341
"""
3342
+ >>> import _colorize
3334
3343
>>> save_colorize = _colorize.COLORIZE
3335
3344
>>> _colorize.COLORIZE = False
3336
3345
@@ -3465,6 +3474,7 @@ def test_syntax_error_subclass_from_stdlib():
3465
3474
3466
3475
def test_syntax_error_with_incorrect_expected_note ():
3467
3476
"""
3477
+ >>> import _colorize
3468
3478
>>> save_colorize = _colorize.COLORIZE
3469
3479
>>> _colorize.COLORIZE = False
3470
3480
0 commit comments