From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Sat, 3 May 2025 16:01:36 +0000 (+0200) Subject: [3.13] gh-133210: Fix `test_rlcompleter` in `--without-doc-strings` mode (GH-133332... X-Git-Tag: v3.13.4~174 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e090f8e3f59f5eec8158c891b30f6450b57dab00;p=thirdparty%2FPython%2Fcpython.git [3.13] gh-133210: Fix `test_rlcompleter` in `--without-doc-strings` mode (GH-133332) (#133348) gh-133210: Fix `test_rlcompleter` in `--without-doc-strings` mode (GH-133332) (cherry picked from commit 881144fa585bfb03441b29a8b62f89154c668fd4) Co-authored-by: sobolevn --- diff --git a/Lib/test/test_rlcompleter.py b/Lib/test/test_rlcompleter.py index 1cff6a218f8d..d403a0fe96be 100644 --- a/Lib/test/test_rlcompleter.py +++ b/Lib/test/test_rlcompleter.py @@ -54,11 +54,26 @@ class TestRlcompleter(unittest.TestCase): ['str.{}('.format(x) for x in dir(str) if x.startswith('s')]) self.assertEqual(self.stdcompleter.attr_matches('tuple.foospamegg'), []) - expected = sorted({'None.%s%s' % (x, - '()' if x in ('__init_subclass__', '__class__') - else '' if x == '__doc__' - else '(') - for x in dir(None)}) + + def create_expected_for_none(): + if not MISSING_C_DOCSTRINGS: + parentheses = ('__init_subclass__', '__class__') + else: + # When `--without-doc-strings` is used, `__class__` + # won't have a known signature. + parentheses = ('__init_subclass__',) + + items = set() + for x in dir(None): + if x in parentheses: + items.add(f'None.{x}()') + elif x == '__doc__': + items.add(f'None.{x}') + else: + items.add(f'None.{x}(') + return sorted(items) + + expected = create_expected_for_none() self.assertEqual(self.stdcompleter.attr_matches('None.'), expected) self.assertEqual(self.stdcompleter.attr_matches('None._'), expected) self.assertEqual(self.stdcompleter.attr_matches('None.__'), expected)