mirror of
https://github.com/python/cpython.git
synced 2025-08-25 03:04:55 +00:00
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.
This commit is contained in:
parent
150af75432
commit
507a574de3
8 changed files with 133 additions and 22 deletions
|
@ -1142,7 +1142,8 @@ class TestDescriptions(unittest.TestCase):
|
|||
'''A static method'''
|
||||
...
|
||||
self.assertEqual(self._get_summary_lines(X.__dict__['sm']),
|
||||
"<staticmethod object>")
|
||||
'sm(...)\n'
|
||||
' A static method\n')
|
||||
self.assertEqual(self._get_summary_lines(X.sm), """\
|
||||
sm(x, y)
|
||||
A static method
|
||||
|
@ -1162,7 +1163,8 @@ sm(x, y)
|
|||
'''A class method'''
|
||||
...
|
||||
self.assertEqual(self._get_summary_lines(X.__dict__['cm']),
|
||||
"<classmethod object>")
|
||||
'cm(...)\n'
|
||||
' A class method\n')
|
||||
self.assertEqual(self._get_summary_lines(X.cm), """\
|
||||
cm(x) method of builtins.type instance
|
||||
A class method
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue