44
55from test import support
66from test .support import import_helper
7- from test .support .pty_helper import FakeInput # used in doctests
87import doctest
98import functools
109import os
1615import tempfile
1716import types
1817import contextlib
19- import _colorize
2018
2119
2220def doctest_skip_if (condition ):
@@ -471,7 +469,7 @@ def basics(): r"""
471469 >>> tests = finder.find(sample_func)
472470
473471 >>> 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)>]
475473
476474The exact name depends on how test_doctest was invoked, so allow for
477475leading path components.
@@ -893,6 +891,7 @@ def basics(): r"""
893891DocTestRunner is used to run DocTest test cases, and to accumulate
894892statistics. Here's a simple DocTest case we can use:
895893
894+ >>> import _colorize
896895 >>> save_colorize = _colorize.COLORIZE
897896 >>> _colorize.COLORIZE = False
898897
@@ -1027,6 +1026,7 @@ def exceptions(): r"""
10271026lines between the first line and the type/value may be omitted or
10281027replaced with any other string:
10291028
1029+ >>> import _colorize
10301030 >>> save_colorize = _colorize.COLORIZE
10311031 >>> _colorize.COLORIZE = False
10321032
@@ -1303,6 +1303,7 @@ def optionflags(): r"""
13031303The DONT_ACCEPT_TRUE_FOR_1 flag disables matches between True/False
13041304and 1/0:
13051305
1306+ >>> import _colorize
13061307 >>> save_colorize = _colorize.COLORIZE
13071308 >>> _colorize.COLORIZE = False
13081309
@@ -1736,6 +1737,7 @@ def option_directives(): r"""
17361737single example. To turn an option on for an example, follow that
17371738example with a comment of the form ``# doctest: +OPTION``:
17381739
1740+ >>> import _colorize
17391741 >>> save_colorize = _colorize.COLORIZE
17401742 >>> _colorize.COLORIZE = False
17411743
@@ -2002,6 +2004,7 @@ def test_debug(): r"""
20022004
20032005Create some fake stdin input, to feed to the debugger:
20042006
2007+ >>> from test.support.pty_helper import FakeInput
20052008 >>> real_stdin = sys.stdin
20062009 >>> sys.stdin = FakeInput(['next', 'print(x)', 'continue'])
20072010
@@ -2031,6 +2034,7 @@ def test_pdb_set_trace():
20312034 with a version that restores stdout. This is necessary for you to
20322035 see debugger output.
20332036
2037+ >>> import _colorize
20342038 >>> save_colorize = _colorize.COLORIZE
20352039 >>> _colorize.COLORIZE = False
20362040
@@ -2048,6 +2052,7 @@ def test_pdb_set_trace():
20482052 To demonstrate this, we'll create a fake standard input that
20492053 captures our debugger input:
20502054
2055+ >>> from test.support.pty_helper import FakeInput
20512056 >>> real_stdin = sys.stdin
20522057 >>> sys.stdin = FakeInput([
20532058 ... 'print(x)', # print data defined by the example
@@ -2086,7 +2091,7 @@ def test_pdb_set_trace():
20862091 ... runner.run(test)
20872092 ... finally:
20882093 ... 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()
20902095 -> import pdb; pdb.set_trace()
20912096 (Pdb) print(y)
20922097 2
@@ -2188,6 +2193,7 @@ def test_pdb_set_trace_nested():
21882193 >>> parser = doctest.DocTestParser()
21892194 >>> runner = doctest.DocTestRunner(verbose=False)
21902195 >>> test = parser.get_doctest(doc, globals(), "foo-bar@baz", "[email protected] ", 0) 2196+ >>> from test.support.pty_helper import FakeInput
21912197 >>> real_stdin = sys.stdin
21922198 >>> sys.stdin = FakeInput([
21932199 ... 'step',
@@ -2700,6 +2706,7 @@ def test_testfile(): r"""
27002706
27012707We don't want color or `-v` in sys.argv for these tests.
27022708
2709+ >>> import _colorize
27032710 >>> save_colorize = _colorize.COLORIZE
27042711 >>> _colorize.COLORIZE = False
27052712
@@ -3007,6 +3014,7 @@ def test_testmod(): r"""
30073014 def test_unicode (): """
30083015Check doctest with a non-ascii filename:
30093016
3017+ >>> import _colorize
30103018 >>> save_colorize = _colorize.COLORIZE
30113019 >>> _colorize.COLORIZE = False
30123020
@@ -3331,6 +3339,7 @@ def test_run_doctestsuite_multiple_times():
33313339
33323340def test_exception_with_note (note ):
33333341 """
3342+ >>> import _colorize
33343343 >>> save_colorize = _colorize.COLORIZE
33353344 >>> _colorize.COLORIZE = False
33363345
@@ -3465,6 +3474,7 @@ def test_syntax_error_subclass_from_stdlib():
34653474
34663475def test_syntax_error_with_incorrect_expected_note ():
34673476 """
3477+ >>> import _colorize
34683478 >>> save_colorize = _colorize.COLORIZE
34693479 >>> _colorize.COLORIZE = False
34703480
0 commit comments