]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-115264: Fix `test_functools` with `-00` mode (#115276)
authorNikita Sobolev <mail@sobolevn.me>
Wed, 13 Mar 2024 06:41:37 +0000 (09:41 +0300)
committerGitHub <noreply@github.com>
Wed, 13 Mar 2024 06:41:37 +0000 (09:41 +0300)
Lib/test/test_functools.py

index 4eb322644fc541b7b39bbb991756db42e50779a1..1a6d8afe6ed6fe62b92c27ab49ef0f5d71a2023e 100644 (file)
@@ -2696,7 +2696,10 @@ class TestSingleDispatch(unittest.TestCase):
             A().static_func
         ):
             with self.subTest(meth=meth):
-                self.assertEqual(meth.__doc__, 'My function docstring')
+                self.assertEqual(meth.__doc__,
+                                 ('My function docstring'
+                                  if support.HAVE_DOCSTRINGS
+                                  else None))
                 self.assertEqual(meth.__annotations__['arg'], int)
 
         self.assertEqual(A.func.__name__, 'func')
@@ -2785,7 +2788,10 @@ class TestSingleDispatch(unittest.TestCase):
             WithSingleDispatch().decorated_classmethod
         ):
             with self.subTest(meth=meth):
-                self.assertEqual(meth.__doc__, 'My function docstring')
+                self.assertEqual(meth.__doc__,
+                                 ('My function docstring'
+                                  if support.HAVE_DOCSTRINGS
+                                  else None))
                 self.assertEqual(meth.__annotations__['arg'], int)
 
         self.assertEqual(
@@ -3128,7 +3134,10 @@ class TestCachedProperty(unittest.TestCase):
         self.assertIsInstance(CachedCostItem.cost, py_functools.cached_property)
 
     def test_doc(self):
-        self.assertEqual(CachedCostItem.cost.__doc__, "The cost of the item.")
+        self.assertEqual(CachedCostItem.cost.__doc__,
+                         ("The cost of the item."
+                          if support.HAVE_DOCSTRINGS
+                          else None))
 
     def test_module(self):
         self.assertEqual(CachedCostItem.cost.__module__, CachedCostItem.__module__)