bpo-43682: @staticmethod inherits attributes (GH-25268)
Static methods (@staticmethod) and class methods (@classmethod) now
inherit the method attributes (__module__, __name__, __qualname__,
__doc__, __annotations__) and have a new __wrapped__ attribute.
Changes:
* Add a repr() method to staticmethod and classmethod types.
* Add tests on the @classmethod decorator.
diff --git a/Lib/test/test_reprlib.py b/Lib/test/test_reprlib.py
index a328810..0555b71 100644
--- a/Lib/test/test_reprlib.py
+++ b/Lib/test/test_reprlib.py
@@ -203,9 +203,9 @@ def test_descriptors(self):
class C:
def foo(cls): pass
x = staticmethod(C.foo)
- self.assertTrue(repr(x).startswith('<staticmethod object at 0x'))
+ self.assertEqual(repr(x), f'<staticmethod({C.foo!r})>')
x = classmethod(C.foo)
- self.assertTrue(repr(x).startswith('<classmethod object at 0x'))
+ self.assertEqual(repr(x), f'<classmethod({C.foo!r})>')
def test_unsortable(self):
# Repr.repr() used to call sorted() on sets, frozensets and dicts