Skip to content

Commit 4912b29

Browse files
authored
gh-133210: Fix test_pydoc in --without-doc-strings mode (#133271)
1 parent a6ddd07 commit 4912b29

File tree

1 file changed

+60
-22
lines changed

1 file changed

+60
-22
lines changed

Lib/test/test_pydoc/test_pydoc.py

+60-22
Original file line numberDiff line numberDiff line change
@@ -1927,18 +1927,28 @@ def test_text_doc_routines_in_class(self, cls=pydocfodder.B):
19271927
self.assertIn(' | global_func(x, y) from test.test_pydoc.pydocfodder', lines)
19281928
self.assertIn(' | global_func_alias = global_func(x, y)', lines)
19291929
self.assertIn(' | global_func2_alias = global_func2(x, y) from test.test_pydoc.pydocfodder', lines)
1930-
self.assertIn(' | count(self, value, /) from builtins.list', lines)
1931-
self.assertIn(' | list_count = count(self, value, /)', lines)
1932-
self.assertIn(' | __repr__(self, /) from builtins.object', lines)
1933-
self.assertIn(' | object_repr = __repr__(self, /)', lines)
1930+
if not support.MISSING_C_DOCSTRINGS:
1931+
self.assertIn(' | count(self, value, /) from builtins.list', lines)
1932+
self.assertIn(' | list_count = count(self, value, /)', lines)
1933+
self.assertIn(' | __repr__(self, /) from builtins.object', lines)
1934+
self.assertIn(' | object_repr = __repr__(self, /)', lines)
1935+
else:
1936+
self.assertIn(' | count(self, object, /) from builtins.list', lines)
1937+
self.assertIn(' | list_count = count(self, object, /)', lines)
1938+
self.assertIn(' | __repr__(...) from builtins.object', lines)
1939+
self.assertIn(' | object_repr = __repr__(...)', lines)
19341940

19351941
lines = self.getsection(result, f' | Static methods {where}:', ' | ' + '-'*70)
19361942
self.assertIn(' | A_classmethod_ref = A_classmethod(x) class method of test.test_pydoc.pydocfodder.A', lines)
19371943
note = '' if cls is pydocfodder.B else ' class method of test.test_pydoc.pydocfodder.B'
19381944
self.assertIn(' | B_classmethod_ref = B_classmethod(x)' + note, lines)
19391945
self.assertIn(' | A_method_ref = A_method() method of test.test_pydoc.pydocfodder.A instance', lines)
1940-
self.assertIn(' | get(key, default=None, /) method of builtins.dict instance', lines)
1941-
self.assertIn(' | dict_get = get(key, default=None, /) method of builtins.dict instance', lines)
1946+
if not support.MISSING_C_DOCSTRINGS:
1947+
self.assertIn(' | get(key, default=None, /) method of builtins.dict instance', lines)
1948+
self.assertIn(' | dict_get = get(key, default=None, /) method of builtins.dict instance', lines)
1949+
else:
1950+
self.assertIn(' | get(...) method of builtins.dict instance', lines)
1951+
self.assertIn(' | dict_get = get(...) method of builtins.dict instance', lines)
19421952

19431953
lines = self.getsection(result, f' | Class methods {where}:', ' | ' + '-'*70)
19441954
self.assertIn(' | B_classmethod(x)', lines)
@@ -1957,10 +1967,16 @@ def test_html_doc_routines_in_class(self, cls=pydocfodder.B):
19571967
self.assertIn('global_func(x, y) from test.test_pydoc.pydocfodder', lines)
19581968
self.assertIn('global_func_alias = global_func(x, y)', lines)
19591969
self.assertIn('global_func2_alias = global_func2(x, y) from test.test_pydoc.pydocfodder', lines)
1960-
self.assertIn('count(self, value, /) from builtins.list', lines)
1961-
self.assertIn('list_count = count(self, value, /)', lines)
1962-
self.assertIn('__repr__(self, /) from builtins.object', lines)
1963-
self.assertIn('object_repr = __repr__(self, /)', lines)
1970+
if not support.MISSING_C_DOCSTRINGS:
1971+
self.assertIn('count(self, value, /) from builtins.list', lines)
1972+
self.assertIn('list_count = count(self, value, /)', lines)
1973+
self.assertIn('__repr__(self, /) from builtins.object', lines)
1974+
self.assertIn('object_repr = __repr__(self, /)', lines)
1975+
else:
1976+
self.assertIn('count(self, object, /) from builtins.list', lines)
1977+
self.assertIn('list_count = count(self, object, /)', lines)
1978+
self.assertIn('__repr__(...) from builtins.object', lines)
1979+
self.assertIn('object_repr = __repr__(...)', lines)
19641980

19651981
lines = self.getsection(result, f'Static methods {where}:', '-'*70)
19661982
self.assertIn('A_classmethod_ref = A_classmethod(x) class method of test.test_pydoc.pydocfodder.A', lines)
@@ -1997,15 +2013,27 @@ def test_text_doc_routines_in_module(self):
19972013
self.assertIn(' A_method3 = A_method() method of B instance', lines)
19982014
self.assertIn(' A_staticmethod_ref = A_staticmethod(x, y)', lines)
19992015
self.assertIn(' A_staticmethod_ref2 = A_staticmethod(y) method of B instance', lines)
2000-
self.assertIn(' get(key, default=None, /) method of builtins.dict instance', lines)
2001-
self.assertIn(' dict_get = get(key, default=None, /) method of builtins.dict instance', lines)
2016+
if not support.MISSING_C_DOCSTRINGS:
2017+
self.assertIn(' get(key, default=None, /) method of builtins.dict instance', lines)
2018+
self.assertIn(' dict_get = get(key, default=None, /) method of builtins.dict instance', lines)
2019+
else:
2020+
self.assertIn(' get(...) method of builtins.dict instance', lines)
2021+
self.assertIn(' dict_get = get(...) method of builtins.dict instance', lines)
2022+
20022023
# unbound methods
20032024
self.assertIn(' B_method(self)', lines)
20042025
self.assertIn(' B_method2 = B_method(self)', lines)
2005-
self.assertIn(' count(self, value, /) unbound builtins.list method', lines)
2006-
self.assertIn(' list_count = count(self, value, /) unbound builtins.list method', lines)
2007-
self.assertIn(' __repr__(self, /) unbound builtins.object method', lines)
2008-
self.assertIn(' object_repr = __repr__(self, /) unbound builtins.object method', lines)
2026+
if not support.MISSING_C_DOCSTRINGS:
2027+
self.assertIn(' count(self, value, /) unbound builtins.list method', lines)
2028+
self.assertIn(' list_count = count(self, value, /) unbound builtins.list method', lines)
2029+
self.assertIn(' __repr__(self, /) unbound builtins.object method', lines)
2030+
self.assertIn(' object_repr = __repr__(self, /) unbound builtins.object method', lines)
2031+
else:
2032+
self.assertIn(' count(self, object, /) unbound builtins.list method', lines)
2033+
self.assertIn(' list_count = count(self, object, /) unbound builtins.list method', lines)
2034+
self.assertIn(' __repr__(...) unbound builtins.object method', lines)
2035+
self.assertIn(' object_repr = __repr__(...) unbound builtins.object method', lines)
2036+
20092037

20102038
def test_html_doc_routines_in_module(self):
20112039
doc = pydoc.HTMLDoc()
@@ -2026,15 +2054,25 @@ def test_html_doc_routines_in_module(self):
20262054
self.assertIn(' A_method3 = A_method() method of B instance', lines)
20272055
self.assertIn(' A_staticmethod_ref = A_staticmethod(x, y)', lines)
20282056
self.assertIn(' A_staticmethod_ref2 = A_staticmethod(y) method of B instance', lines)
2029-
self.assertIn(' get(key, default=None, /) method of builtins.dict instance', lines)
2030-
self.assertIn(' dict_get = get(key, default=None, /) method of builtins.dict instance', lines)
2057+
if not support.MISSING_C_DOCSTRINGS:
2058+
self.assertIn(' get(key, default=None, /) method of builtins.dict instance', lines)
2059+
self.assertIn(' dict_get = get(key, default=None, /) method of builtins.dict instance', lines)
2060+
else:
2061+
self.assertIn(' get(...) method of builtins.dict instance', lines)
2062+
self.assertIn(' dict_get = get(...) method of builtins.dict instance', lines)
20312063
# unbound methods
20322064
self.assertIn(' B_method(self)', lines)
20332065
self.assertIn(' B_method2 = B_method(self)', lines)
2034-
self.assertIn(' count(self, value, /) unbound builtins.list method', lines)
2035-
self.assertIn(' list_count = count(self, value, /) unbound builtins.list method', lines)
2036-
self.assertIn(' __repr__(self, /) unbound builtins.object method', lines)
2037-
self.assertIn(' object_repr = __repr__(self, /) unbound builtins.object method', lines)
2066+
if not support.MISSING_C_DOCSTRINGS:
2067+
self.assertIn(' count(self, value, /) unbound builtins.list method', lines)
2068+
self.assertIn(' list_count = count(self, value, /) unbound builtins.list method', lines)
2069+
self.assertIn(' __repr__(self, /) unbound builtins.object method', lines)
2070+
self.assertIn(' object_repr = __repr__(self, /) unbound builtins.object method', lines)
2071+
else:
2072+
self.assertIn(' count(self, object, /) unbound builtins.list method', lines)
2073+
self.assertIn(' list_count = count(self, object, /) unbound builtins.list method', lines)
2074+
self.assertIn(' __repr__(...) unbound builtins.object method', lines)
2075+
self.assertIn(' object_repr = __repr__(...) unbound builtins.object method', lines)
20382076

20392077

20402078
@unittest.skipIf(

0 commit comments

Comments
 (0)