Skip to content

Commit b64cc74

Browse files
[3.13] gh-133210: Fix test_pydoc in --without-doc-strings mode (GH-133271) (#133288)
gh-133210: Fix `test_pydoc` in `--without-doc-strings` mode (GH-133271) (cherry picked from commit 4912b29) Co-authored-by: sobolevn <mail@sobolevn.me>
1 parent ae775dc commit b64cc74

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
@@ -1907,18 +1907,28 @@ def test_text_doc_routines_in_class(self, cls=pydocfodder.B):
19071907
self.assertIn(' | global_func(x, y) from test.test_pydoc.pydocfodder', lines)
19081908
self.assertIn(' | global_func_alias = global_func(x, y)', lines)
19091909
self.assertIn(' | global_func2_alias = global_func2(x, y) from test.test_pydoc.pydocfodder', lines)
1910-
self.assertIn(' | count(self, value, /) from builtins.list', lines)
1911-
self.assertIn(' | list_count = count(self, value, /)', lines)
1912-
self.assertIn(' | __repr__(self, /) from builtins.object', lines)
1913-
self.assertIn(' | object_repr = __repr__(self, /)', lines)
1910+
if not support.MISSING_C_DOCSTRINGS:
1911+
self.assertIn(' | count(self, value, /) from builtins.list', lines)
1912+
self.assertIn(' | list_count = count(self, value, /)', lines)
1913+
self.assertIn(' | __repr__(self, /) from builtins.object', lines)
1914+
self.assertIn(' | object_repr = __repr__(self, /)', lines)
1915+
else:
1916+
self.assertIn(' | count(self, object, /) from builtins.list', lines)
1917+
self.assertIn(' | list_count = count(self, object, /)', lines)
1918+
self.assertIn(' | __repr__(...) from builtins.object', lines)
1919+
self.assertIn(' | object_repr = __repr__(...)', lines)
19141920

19151921
lines = self.getsection(result, f' | Static methods {where}:', ' | ' + '-'*70)
19161922
self.assertIn(' | A_classmethod_ref = A_classmethod(x) class method of test.test_pydoc.pydocfodder.A', lines)
19171923
note = '' if cls is pydocfodder.B else ' class method of test.test_pydoc.pydocfodder.B'
19181924
self.assertIn(' | B_classmethod_ref = B_classmethod(x)' + note, lines)
19191925
self.assertIn(' | A_method_ref = A_method() method of test.test_pydoc.pydocfodder.A instance', lines)
1920-
self.assertIn(' | get(key, default=None, /) method of builtins.dict instance', lines)
1921-
self.assertIn(' | dict_get = get(key, default=None, /) method of builtins.dict instance', lines)
1926+
if not support.MISSING_C_DOCSTRINGS:
1927+
self.assertIn(' | get(key, default=None, /) method of builtins.dict instance', lines)
1928+
self.assertIn(' | dict_get = get(key, default=None, /) method of builtins.dict instance', lines)
1929+
else:
1930+
self.assertIn(' | get(...) method of builtins.dict instance', lines)
1931+
self.assertIn(' | dict_get = get(...) method of builtins.dict instance', lines)
19221932

19231933
lines = self.getsection(result, f' | Class methods {where}:', ' | ' + '-'*70)
19241934
self.assertIn(' | B_classmethod(x)', lines)
@@ -1937,10 +1947,16 @@ def test_html_doc_routines_in_class(self, cls=pydocfodder.B):
19371947
self.assertIn('global_func(x, y) from test.test_pydoc.pydocfodder', lines)
19381948
self.assertIn('global_func_alias = global_func(x, y)', lines)
19391949
self.assertIn('global_func2_alias = global_func2(x, y) from test.test_pydoc.pydocfodder', lines)
1940-
self.assertIn('count(self, value, /) from builtins.list', lines)
1941-
self.assertIn('list_count = count(self, value, /)', lines)
1942-
self.assertIn('__repr__(self, /) from builtins.object', lines)
1943-
self.assertIn('object_repr = __repr__(self, /)', lines)
1950+
if not support.MISSING_C_DOCSTRINGS:
1951+
self.assertIn('count(self, value, /) from builtins.list', lines)
1952+
self.assertIn('list_count = count(self, value, /)', lines)
1953+
self.assertIn('__repr__(self, /) from builtins.object', lines)
1954+
self.assertIn('object_repr = __repr__(self, /)', lines)
1955+
else:
1956+
self.assertIn('count(self, object, /) from builtins.list', lines)
1957+
self.assertIn('list_count = count(self, object, /)', lines)
1958+
self.assertIn('__repr__(...) from builtins.object', lines)
1959+
self.assertIn('object_repr = __repr__(...)', lines)
19441960

19451961
lines = self.getsection(result, f'Static methods {where}:', '-'*70)
19461962
self.assertIn('A_classmethod_ref = A_classmethod(x) class method of test.test_pydoc.pydocfodder.A', lines)
@@ -1977,15 +1993,27 @@ def test_text_doc_routines_in_module(self):
19771993
self.assertIn(' A_method3 = A_method() method of B instance', lines)
19781994
self.assertIn(' A_staticmethod_ref = A_staticmethod(x, y)', lines)
19791995
self.assertIn(' A_staticmethod_ref2 = A_staticmethod(y) method of B instance', lines)
1980-
self.assertIn(' get(key, default=None, /) method of builtins.dict instance', lines)
1981-
self.assertIn(' dict_get = get(key, default=None, /) method of builtins.dict instance', lines)
1996+
if not support.MISSING_C_DOCSTRINGS:
1997+
self.assertIn(' get(key, default=None, /) method of builtins.dict instance', lines)
1998+
self.assertIn(' dict_get = get(key, default=None, /) method of builtins.dict instance', lines)
1999+
else:
2000+
self.assertIn(' get(...) method of builtins.dict instance', lines)
2001+
self.assertIn(' dict_get = get(...) method of builtins.dict instance', lines)
2002+
19822003
# unbound methods
19832004
self.assertIn(' B_method(self)', lines)
19842005
self.assertIn(' B_method2 = B_method(self)', lines)
1985-
self.assertIn(' count(self, value, /) unbound builtins.list method', lines)
1986-
self.assertIn(' list_count = count(self, value, /) unbound builtins.list method', lines)
1987-
self.assertIn(' __repr__(self, /) unbound builtins.object method', lines)
1988-
self.assertIn(' object_repr = __repr__(self, /) unbound builtins.object method', lines)
2006+
if not support.MISSING_C_DOCSTRINGS:
2007+
self.assertIn(' count(self, value, /) unbound builtins.list method', lines)
2008+
self.assertIn(' list_count = count(self, value, /) unbound builtins.list method', lines)
2009+
self.assertIn(' __repr__(self, /) unbound builtins.object method', lines)
2010+
self.assertIn(' object_repr = __repr__(self, /) unbound builtins.object method', lines)
2011+
else:
2012+
self.assertIn(' count(self, object, /) unbound builtins.list method', lines)
2013+
self.assertIn(' list_count = count(self, object, /) unbound builtins.list method', lines)
2014+
self.assertIn(' __repr__(...) unbound builtins.object method', lines)
2015+
self.assertIn(' object_repr = __repr__(...) unbound builtins.object method', lines)
2016+
19892017

19902018
def test_html_doc_routines_in_module(self):
19912019
doc = pydoc.HTMLDoc()
@@ -2006,15 +2034,25 @@ def test_html_doc_routines_in_module(self):
20062034
self.assertIn(' A_method3 = A_method() method of B instance', lines)
20072035
self.assertIn(' A_staticmethod_ref = A_staticmethod(x, y)', lines)
20082036
self.assertIn(' A_staticmethod_ref2 = A_staticmethod(y) method of B instance', lines)
2009-
self.assertIn(' get(key, default=None, /) method of builtins.dict instance', lines)
2010-
self.assertIn(' dict_get = get(key, default=None, /) method of builtins.dict instance', lines)
2037+
if not support.MISSING_C_DOCSTRINGS:
2038+
self.assertIn(' get(key, default=None, /) method of builtins.dict instance', lines)
2039+
self.assertIn(' dict_get = get(key, default=None, /) method of builtins.dict instance', lines)
2040+
else:
2041+
self.assertIn(' get(...) method of builtins.dict instance', lines)
2042+
self.assertIn(' dict_get = get(...) method of builtins.dict instance', lines)
20112043
# unbound methods
20122044
self.assertIn(' B_method(self)', lines)
20132045
self.assertIn(' B_method2 = B_method(self)', lines)
2014-
self.assertIn(' count(self, value, /) unbound builtins.list method', lines)
2015-
self.assertIn(' list_count = count(self, value, /) unbound builtins.list method', lines)
2016-
self.assertIn(' __repr__(self, /) unbound builtins.object method', lines)
2017-
self.assertIn(' object_repr = __repr__(self, /) unbound builtins.object method', lines)
2046+
if not support.MISSING_C_DOCSTRINGS:
2047+
self.assertIn(' count(self, value, /) unbound builtins.list method', lines)
2048+
self.assertIn(' list_count = count(self, value, /) unbound builtins.list method', lines)
2049+
self.assertIn(' __repr__(self, /) unbound builtins.object method', lines)
2050+
self.assertIn(' object_repr = __repr__(self, /) unbound builtins.object method', lines)
2051+
else:
2052+
self.assertIn(' count(self, object, /) unbound builtins.list method', lines)
2053+
self.assertIn(' list_count = count(self, object, /) unbound builtins.list method', lines)
2054+
self.assertIn(' __repr__(...) unbound builtins.object method', lines)
2055+
self.assertIn(' object_repr = __repr__(...) unbound builtins.object method', lines)
20182056

20192057

20202058
@unittest.skipIf(

0 commit comments

Comments
 (0)