]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.11] gh-115264: Fix `test_functools` with `-00` mode (GH-115276) (#116706)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 13 Mar 2024 07:05:41 +0000 (08:05 +0100)
committerGitHub <noreply@github.com>
Wed, 13 Mar 2024 07:05:41 +0000 (07:05 +0000)
gh-115264: Fix `test_functools` with `-00` mode (GH-115276)
(cherry picked from commit 27df81d5643f32be6ae84a00c5cf84b58e849b21)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Lib/test/test_functools.py

index fb6e1860ac11fe8c9865e153ce169f184a3a1086..ee15345806979672d64136dcaf89e79e1cc55229 100644 (file)
@@ -2604,7 +2604,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')
@@ -2693,7 +2696,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(
@@ -3057,7 +3063,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))
 
 
 if __name__ == '__main__':