Skip to content

Commit 9c93350

Browse files
gh-108303: Move all doctest related files and tests to Lib/test/test_doctest/ (#112109)
Co-authored-by: Brett Cannon <[email protected]>
1 parent 2ff072f commit 9c93350

18 files changed

+153
-117
lines changed

Doc/library/doctest.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ That's all you need to know to start making productive use of :mod:`doctest`!
134134
Jump in. The following sections provide full details. Note that there are many
135135
examples of doctests in the standard Python test suite and libraries.
136136
Especially useful examples can be found in the standard test file
137-
:file:`Lib/test/test_doctest.py`.
137+
:file:`Lib/test/test_doctest/test_doctest.py`.
138138

139139

140140
.. _doctest-simple-testmod:

Lib/test/libregrtest/findtests.py

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
SPLITTESTDIRS: set[TestName] = {
2020
"test_asyncio",
2121
"test_concurrent_futures",
22+
"test_doctests",
2223
"test_future_stmt",
2324
"test_gdb",
2425
"test_inspect",

Lib/test/support/pty_helper.py

+20
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,23 @@ def terminate(proc):
5858
input = b"" # Stop writing
5959
if not input:
6060
sel.modify(master, selectors.EVENT_READ)
61+
62+
63+
######################################################################
64+
## Fake stdin (for testing interactive debugging)
65+
######################################################################
66+
67+
class FakeInput:
68+
"""
69+
A fake input stream for pdb's interactive debugger. Whenever a
70+
line is read, print it (to simulate the user typing it), and then
71+
return it. The set of lines to return is specified in the
72+
constructor; they should not have trailing newlines.
73+
"""
74+
def __init__(self, lines):
75+
self.lines = lines
76+
77+
def readline(self):
78+
line = self.lines.pop(0)
79+
print(line)
80+
return line + '\n'

Lib/test/test_doctest/__init__.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import os
2+
from test.support import load_package_tests
3+
4+
def load_tests(*args):
5+
return load_package_tests(os.path.dirname(__file__), *args)
File renamed without changes.

Lib/test/sample_doctest.py renamed to Lib/test/test_doctest/sample_doctest.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ def bar():
3232
def test_silly_setup():
3333
"""
3434
35-
>>> import test.test_doctest
36-
>>> test.test_doctest.sillySetup
35+
>>> import test.test_doctest.test_doctest
36+
>>> test.test_doctest.test_doctest.sillySetup
3737
True
3838
"""
3939

0 commit comments

Comments
 (0)