aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2021-04-12 00:21:22 +0200
committerGitHub <noreply@github.com>2021-04-12 00:21:22 +0200
commit553ee2781a37ac9d2068da3e1325a780ca79e21e (patch)
tree599710562c5961edb6d7365761da242a8c122680 /Lib/test
parent53114ffef1d4facf9aa5545e711abbbda66f672a (diff)
downloadcpython-553ee2781a37ac9d2068da3e1325a780ca79e21e.tar.gz
cpython-553ee2781a37ac9d2068da3e1325a780ca79e21e.zip
bpo-43682: Make staticmethod objects callable (GH-25117)
Static methods (@staticmethod) are now callable as regular functions.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_decorators.py12
-rw-r--r--Lib/test/test_pydoc.py2
2 files changed, 9 insertions, 5 deletions
diff --git a/Lib/test/test_decorators.py b/Lib/test/test_decorators.py
index 7d0243ab199..d4353457933 100644
--- a/Lib/test/test_decorators.py
+++ b/Lib/test/test_decorators.py
@@ -91,14 +91,18 @@ class TestDecorators(unittest.TestCase):
getattr(func, attr))
self.assertEqual(repr(wrapper), format_str.format(func))
-
- self.assertRaises(TypeError, wrapper, 1)
+ return wrapper
def test_staticmethod(self):
- self.check_wrapper_attrs(staticmethod, '<staticmethod({!r})>')
+ wrapper = self.check_wrapper_attrs(staticmethod, '<staticmethod({!r})>')
+
+ # bpo-43682: Static methods are callable since Python 3.10
+ self.assertEqual(wrapper(1), 1)
def test_classmethod(self):
- self.check_wrapper_attrs(classmethod, '<classmethod({!r})>')
+ wrapper = self.check_wrapper_attrs(classmethod, '<classmethod({!r})>')
+
+ self.assertRaises(TypeError, wrapper, 1)
def test_dotted(self):
decorators = MiscDecorators()
diff --git a/Lib/test/test_pydoc.py b/Lib/test/test_pydoc.py
index e94ebd30160..9bde0c75bc9 100644
--- a/Lib/test/test_pydoc.py
+++ b/Lib/test/test_pydoc.py
@@ -1142,7 +1142,7 @@ class TestDescriptions(unittest.TestCase):
'''A static method'''
...
self.assertEqual(self._get_summary_lines(X.__dict__['sm']),
- 'sm(...)\n'
+ 'sm(x, y)\n'
' A static method\n')
self.assertEqual(self._get_summary_lines(X.sm), """\
sm(x, y)