diff options
author | Victor Stinner <vstinner@python.org> | 2021-04-09 15:51:22 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-09 15:51:22 (GMT) |
commit | 507a574de31a1bd7fed8ba4f04afa285d985109b (patch) | |
tree | 44fb249533ae98698ef7736bc050df450f9a07e1 /Lib/test/test_reprlib.py | |
parent | 150af7543214e1541fa582374502ac1cd70e8eb4 (diff) | |
download | cpython-507a574de31a1bd7fed8ba4f04afa285d985109b.zip cpython-507a574de31a1bd7fed8ba4f04afa285d985109b.tar.gz cpython-507a574de31a1bd7fed8ba4f04afa285d985109b.tar.bz2 |
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.
Diffstat (limited to 'Lib/test/test_reprlib.py')
-rw-r--r-- | Lib/test/test_reprlib.py | 4 |
1 files changed, 2 insertions, 2 deletions
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 @@ class ReprTests(unittest.TestCase): 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 |