mirror of
https://github.com/python/cpython.git
synced 2025-08-09 19:38:42 +00:00
[3.12] gh-108303: Move all pydoc
related files to test_pydoc
(GH-114506) (#115502)
(cherry picked from commit ccc76c3e88
)
This commit is contained in:
parent
0e4f73b8e4
commit
9bc32cdc36
7 changed files with 32 additions and 25 deletions
|
@ -529,7 +529,7 @@ class Doc:
|
||||||
'_thread', 'zipimport') or
|
'_thread', 'zipimport') or
|
||||||
(file.startswith(basedir) and
|
(file.startswith(basedir) and
|
||||||
not file.startswith(os.path.join(basedir, 'site-packages')))) and
|
not file.startswith(os.path.join(basedir, 'site-packages')))) and
|
||||||
object.__name__ not in ('xml.etree', 'test.pydoc_mod')):
|
object.__name__ not in ('xml.etree', 'test.test_pydoc.pydoc_mod')):
|
||||||
if docloc.startswith(("http://", "https://")):
|
if docloc.startswith(("http://", "https://")):
|
||||||
docloc = "{}/{}.html".format(docloc.rstrip("/"), object.__name__.lower())
|
docloc = "{}/{}.html".format(docloc.rstrip("/"), object.__name__.lower())
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -23,6 +23,7 @@ SPLITTESTDIRS: set[TestName] = {
|
||||||
"test_future_stmt",
|
"test_future_stmt",
|
||||||
"test_gdb",
|
"test_gdb",
|
||||||
"test_inspect",
|
"test_inspect",
|
||||||
|
"test_pydoc",
|
||||||
"test_multiprocessing_fork",
|
"test_multiprocessing_fork",
|
||||||
"test_multiprocessing_forkserver",
|
"test_multiprocessing_forkserver",
|
||||||
"test_multiprocessing_spawn",
|
"test_multiprocessing_spawn",
|
||||||
|
|
6
Lib/test/test_pydoc/__init__.py
Normal file
6
Lib/test/test_pydoc/__init__.py
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
import os
|
||||||
|
from test import support
|
||||||
|
|
||||||
|
|
||||||
|
def load_tests(*args):
|
||||||
|
return support.load_package_tests(os.path.dirname(__file__), *args)
|
|
@ -32,8 +32,8 @@ from test.support import (reap_children, captured_output, captured_stdout,
|
||||||
captured_stderr, is_emscripten, is_wasi,
|
captured_stderr, is_emscripten, is_wasi,
|
||||||
requires_docstrings, MISSING_C_DOCSTRINGS)
|
requires_docstrings, MISSING_C_DOCSTRINGS)
|
||||||
from test.support.os_helper import (TESTFN, rmtree, unlink)
|
from test.support.os_helper import (TESTFN, rmtree, unlink)
|
||||||
from test import pydoc_mod
|
from test.test_pydoc import pydoc_mod
|
||||||
from test import pydocfodder
|
from test.test_pydoc import pydocfodder
|
||||||
|
|
||||||
|
|
||||||
class nonascii:
|
class nonascii:
|
||||||
|
@ -50,7 +50,7 @@ else:
|
||||||
|
|
||||||
expected_text_pattern = """
|
expected_text_pattern = """
|
||||||
NAME
|
NAME
|
||||||
test.pydoc_mod - This is a test module for test_pydoc
|
test.test_pydoc.pydoc_mod - This is a test module for test_pydoc
|
||||||
%s
|
%s
|
||||||
CLASSES
|
CLASSES
|
||||||
builtins.object
|
builtins.object
|
||||||
|
@ -123,7 +123,7 @@ FUNCTIONS
|
||||||
|
|
||||||
DATA
|
DATA
|
||||||
__xyz__ = 'X, Y and Z'
|
__xyz__ = 'X, Y and Z'
|
||||||
c_alias = test.pydoc_mod.C[int]
|
c_alias = test.test_pydoc.pydoc_mod.C[int]
|
||||||
list_alias1 = typing.List[int]
|
list_alias1 = typing.List[int]
|
||||||
list_alias2 = list[int]
|
list_alias2 = list[int]
|
||||||
type_union1 = typing.Union[int, str]
|
type_union1 = typing.Union[int, str]
|
||||||
|
@ -146,7 +146,7 @@ expected_text_data_docstrings = tuple('\n | ' + s if s else ''
|
||||||
for s in expected_data_docstrings)
|
for s in expected_data_docstrings)
|
||||||
|
|
||||||
html2text_of_expected = """
|
html2text_of_expected = """
|
||||||
test.pydoc_mod (version 1.2.3.4)
|
test.test_pydoc.pydoc_mod (version 1.2.3.4)
|
||||||
This is a test module for test_pydoc
|
This is a test module for test_pydoc
|
||||||
|
|
||||||
Modules
|
Modules
|
||||||
|
@ -211,7 +211,7 @@ Functions
|
||||||
|
|
||||||
Data
|
Data
|
||||||
__xyz__ = 'X, Y and Z'
|
__xyz__ = 'X, Y and Z'
|
||||||
c_alias = test.pydoc_mod.C[int]
|
c_alias = test.test_pydoc.pydoc_mod.C[int]
|
||||||
list_alias1 = typing.List[int]
|
list_alias1 = typing.List[int]
|
||||||
list_alias2 = list[int]
|
list_alias2 = list[int]
|
||||||
type_union1 = typing.Union[int, str]
|
type_union1 = typing.Union[int, str]
|
||||||
|
@ -340,7 +340,7 @@ def get_pydoc_link(module):
|
||||||
"Returns a documentation web link of a module"
|
"Returns a documentation web link of a module"
|
||||||
abspath = os.path.abspath
|
abspath = os.path.abspath
|
||||||
dirname = os.path.dirname
|
dirname = os.path.dirname
|
||||||
basedir = dirname(dirname(abspath(__file__)))
|
basedir = dirname(dirname(dirname(abspath(__file__))))
|
||||||
doc = pydoc.TextDoc()
|
doc = pydoc.TextDoc()
|
||||||
loc = doc.getdocloc(module, basedir=basedir)
|
loc = doc.getdocloc(module, basedir=basedir)
|
||||||
return loc
|
return loc
|
||||||
|
@ -487,7 +487,7 @@ class PydocDocTest(unittest.TestCase):
|
||||||
|
|
||||||
@requires_docstrings
|
@requires_docstrings
|
||||||
def test_not_ascii(self):
|
def test_not_ascii(self):
|
||||||
result = run_pydoc('test.test_pydoc.nonascii', PYTHONIOENCODING='ascii')
|
result = run_pydoc('test.test_pydoc.test_pydoc.nonascii', PYTHONIOENCODING='ascii')
|
||||||
encoded = nonascii.__doc__.encode('ascii', 'backslashreplace')
|
encoded = nonascii.__doc__.encode('ascii', 'backslashreplace')
|
||||||
self.assertIn(encoded, result)
|
self.assertIn(encoded, result)
|
||||||
|
|
||||||
|
@ -667,9 +667,9 @@ class PydocDocTest(unittest.TestCase):
|
||||||
buf = StringIO()
|
buf = StringIO()
|
||||||
helper = pydoc.Helper(output=buf)
|
helper = pydoc.Helper(output=buf)
|
||||||
unused, doc_loc = get_pydoc_text(pydoc_mod)
|
unused, doc_loc = get_pydoc_text(pydoc_mod)
|
||||||
module = "test.pydoc_mod"
|
module = "test.test_pydoc.pydoc_mod"
|
||||||
help_header = """
|
help_header = """
|
||||||
Help on module test.pydoc_mod in test:
|
Help on module test.test_pydoc.pydoc_mod in test.test_pydoc:
|
||||||
|
|
||||||
""".lstrip()
|
""".lstrip()
|
||||||
help_header = textwrap.dedent(help_header)
|
help_header = textwrap.dedent(help_header)
|
||||||
|
@ -1050,7 +1050,6 @@ class TestDescriptions(unittest.TestCase):
|
||||||
|
|
||||||
def test_module(self):
|
def test_module(self):
|
||||||
# Check that pydocfodder module can be described
|
# Check that pydocfodder module can be described
|
||||||
from test import pydocfodder
|
|
||||||
doc = pydoc.render_doc(pydocfodder)
|
doc = pydoc.render_doc(pydocfodder)
|
||||||
self.assertIn("pydocfodder", doc)
|
self.assertIn("pydocfodder", doc)
|
||||||
|
|
||||||
|
@ -1229,7 +1228,7 @@ sm(x, y)
|
||||||
'cm(...)\n'
|
'cm(...)\n'
|
||||||
' A class method\n')
|
' A class method\n')
|
||||||
self.assertEqual(self._get_summary_lines(X.cm), """\
|
self.assertEqual(self._get_summary_lines(X.cm), """\
|
||||||
cm(x) class method of test.test_pydoc.X
|
cm(x) class method of test.test_pydoc.test_pydoc.X
|
||||||
A class method
|
A class method
|
||||||
""")
|
""")
|
||||||
self.assertIn("""
|
self.assertIn("""
|
||||||
|
@ -1411,19 +1410,19 @@ class PydocFodderTest(unittest.TestCase):
|
||||||
lines = self.getsection(result, f' | Methods {where}:', ' | ' + '-'*70)
|
lines = self.getsection(result, f' | Methods {where}:', ' | ' + '-'*70)
|
||||||
self.assertIn(' | A_method_alias = A_method(self)', lines)
|
self.assertIn(' | A_method_alias = A_method(self)', lines)
|
||||||
self.assertIn(' | B_method_alias = B_method(self)', lines)
|
self.assertIn(' | B_method_alias = B_method(self)', lines)
|
||||||
self.assertIn(' | A_staticmethod(x, y) from test.pydocfodder.A', lines)
|
self.assertIn(' | A_staticmethod(x, y) from test.test_pydoc.pydocfodder.A', lines)
|
||||||
self.assertIn(' | A_staticmethod_alias = A_staticmethod(x, y)', lines)
|
self.assertIn(' | A_staticmethod_alias = A_staticmethod(x, y)', lines)
|
||||||
self.assertIn(' | global_func(x, y) from test.pydocfodder', lines)
|
self.assertIn(' | global_func(x, y) from test.test_pydoc.pydocfodder', lines)
|
||||||
self.assertIn(' | global_func_alias = global_func(x, y)', lines)
|
self.assertIn(' | global_func_alias = global_func(x, y)', lines)
|
||||||
self.assertIn(' | global_func2_alias = global_func2(x, y) from test.pydocfodder', lines)
|
self.assertIn(' | global_func2_alias = global_func2(x, y) from test.test_pydoc.pydocfodder', lines)
|
||||||
self.assertIn(' | __repr__(self, /) from builtins.object', lines)
|
self.assertIn(' | __repr__(self, /) from builtins.object', lines)
|
||||||
self.assertIn(' | object_repr = __repr__(self, /)', lines)
|
self.assertIn(' | object_repr = __repr__(self, /)', lines)
|
||||||
|
|
||||||
lines = self.getsection(result, f' | Static methods {where}:', ' | ' + '-'*70)
|
lines = self.getsection(result, f' | Static methods {where}:', ' | ' + '-'*70)
|
||||||
self.assertIn(' | A_classmethod_ref = A_classmethod(x) class method of test.pydocfodder.A', lines)
|
self.assertIn(' | A_classmethod_ref = A_classmethod(x) class method of test.test_pydoc.pydocfodder.A', lines)
|
||||||
note = '' if cls is pydocfodder.B else ' class method of test.pydocfodder.B'
|
note = '' if cls is pydocfodder.B else ' class method of test.test_pydoc.pydocfodder.B'
|
||||||
self.assertIn(' | B_classmethod_ref = B_classmethod(x)' + note, lines)
|
self.assertIn(' | B_classmethod_ref = B_classmethod(x)' + note, lines)
|
||||||
self.assertIn(' | A_method_ref = A_method() method of test.pydocfodder.A instance', lines)
|
self.assertIn(' | A_method_ref = A_method() method of test.test_pydoc.pydocfodder.A instance', lines)
|
||||||
self.assertIn(' | get(key, default=None, /) method of builtins.dict instance', lines)
|
self.assertIn(' | get(key, default=None, /) method of builtins.dict instance', lines)
|
||||||
self.assertIn(' | dict_get = get(key, default=None, /) method of builtins.dict instance', lines)
|
self.assertIn(' | dict_get = get(key, default=None, /) method of builtins.dict instance', lines)
|
||||||
|
|
||||||
|
@ -1439,19 +1438,19 @@ class PydocFodderTest(unittest.TestCase):
|
||||||
lines = self.getsection(result, f'Methods {where}:', '-'*70)
|
lines = self.getsection(result, f'Methods {where}:', '-'*70)
|
||||||
self.assertIn('A_method_alias = A_method(self)', lines)
|
self.assertIn('A_method_alias = A_method(self)', lines)
|
||||||
self.assertIn('B_method_alias = B_method(self)', lines)
|
self.assertIn('B_method_alias = B_method(self)', lines)
|
||||||
self.assertIn('A_staticmethod(x, y) from test.pydocfodder.A', lines)
|
self.assertIn('A_staticmethod(x, y) from test.test_pydoc.pydocfodder.A', lines)
|
||||||
self.assertIn('A_staticmethod_alias = A_staticmethod(x, y)', lines)
|
self.assertIn('A_staticmethod_alias = A_staticmethod(x, y)', lines)
|
||||||
self.assertIn('global_func(x, y) from test.pydocfodder', lines)
|
self.assertIn('global_func(x, y) from test.test_pydoc.pydocfodder', lines)
|
||||||
self.assertIn('global_func_alias = global_func(x, y)', lines)
|
self.assertIn('global_func_alias = global_func(x, y)', lines)
|
||||||
self.assertIn('global_func2_alias = global_func2(x, y) from test.pydocfodder', lines)
|
self.assertIn('global_func2_alias = global_func2(x, y) from test.test_pydoc.pydocfodder', lines)
|
||||||
self.assertIn('__repr__(self, /) from builtins.object', lines)
|
self.assertIn('__repr__(self, /) from builtins.object', lines)
|
||||||
self.assertIn('object_repr = __repr__(self, /)', lines)
|
self.assertIn('object_repr = __repr__(self, /)', lines)
|
||||||
|
|
||||||
lines = self.getsection(result, f'Static methods {where}:', '-'*70)
|
lines = self.getsection(result, f'Static methods {where}:', '-'*70)
|
||||||
self.assertIn('A_classmethod_ref = A_classmethod(x) class method of test.pydocfodder.A', lines)
|
self.assertIn('A_classmethod_ref = A_classmethod(x) class method of test.test_pydoc.pydocfodder.A', lines)
|
||||||
note = '' if cls is pydocfodder.B else ' class method of test.pydocfodder.B'
|
note = '' if cls is pydocfodder.B else ' class method of test.test_pydoc.pydocfodder.B'
|
||||||
self.assertIn('B_classmethod_ref = B_classmethod(x)' + note, lines)
|
self.assertIn('B_classmethod_ref = B_classmethod(x)' + note, lines)
|
||||||
self.assertIn('A_method_ref = A_method() method of test.pydocfodder.A instance', lines)
|
self.assertIn('A_method_ref = A_method() method of test.test_pydoc.pydocfodder.A instance', lines)
|
||||||
|
|
||||||
lines = self.getsection(result, f'Class methods {where}:', '-'*70)
|
lines = self.getsection(result, f'Class methods {where}:', '-'*70)
|
||||||
self.assertIn('B_classmethod(x)', lines)
|
self.assertIn('B_classmethod(x)', lines)
|
|
@ -2208,6 +2208,7 @@ TESTSUBDIRS= idlelib/idle_test \
|
||||||
test/test_lib2to3/data/fixers/myfixes \
|
test/test_lib2to3/data/fixers/myfixes \
|
||||||
test/test_module \
|
test/test_module \
|
||||||
test/test_peg_generator \
|
test/test_peg_generator \
|
||||||
|
test/test_pydoc \
|
||||||
test/test_sqlite3 \
|
test/test_sqlite3 \
|
||||||
test/test_tkinter \
|
test/test_tkinter \
|
||||||
test/test_tomllib \
|
test/test_tomllib \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue