https://github.com/python/cpython/commit/881144fa585bfb03441b29a8b62f89154c668fd4
commit: 881144fa585bfb03441b29a8b62f89154c668fd4
branch: main
author: sobolevn <m...@sobolevn.me>
committer: sobolevn <m...@sobolevn.me>
date: 2025-05-03T18:38:27+03:00
summary:

gh-133210: Fix `test_rlcompleter` in `--without-doc-strings` mode (#133332)

files:
M Lib/test/test_rlcompleter.py

diff --git a/Lib/test/test_rlcompleter.py b/Lib/test/test_rlcompleter.py
index 1cff6a218f8d75..d403a0fe96be3d 100644
--- a/Lib/test/test_rlcompleter.py
+++ b/Lib/test/test_rlcompleter.py
@@ -54,11 +54,26 @@ def test_attr_matches(self):
                          ['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)

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to