summaryrefslogtreecommitdiff
path: root/Lib/test/test_decorators.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_decorators.py')
-rw-r--r--Lib/test/test_decorators.py26
1 files changed, 22 insertions, 4 deletions
diff --git a/Lib/test/test_decorators.py b/Lib/test/test_decorators.py
index 298979e509..7d0243ab19 100644
--- a/Lib/test/test_decorators.py
+++ b/Lib/test/test_decorators.py
@@ -1,3 +1,4 @@
+from test import support
import unittest
def funcattrs(**kwds):
@@ -76,11 +77,28 @@ class TestDecorators(unittest.TestCase):
self.assertEqual(C.foo(), 42)
self.assertEqual(C().foo(), 42)
- def test_staticmethod_function(self):
- @staticmethod
- def notamethod(x):
+ def check_wrapper_attrs(self, method_wrapper, format_str):
+ def func(x):
return x
- self.assertRaises(TypeError, notamethod, 1)
+ wrapper = method_wrapper(func)
+
+ self.assertIs(wrapper.__func__, func)
+ self.assertIs(wrapper.__wrapped__, func)
+
+ for attr in ('__module__', '__qualname__', '__name__',
+ '__doc__', '__annotations__'):
+ self.assertIs(getattr(wrapper, attr),
+ getattr(func, attr))
+
+ self.assertEqual(repr(wrapper), format_str.format(func))
+
+ self.assertRaises(TypeError, wrapper, 1)
+
+ def test_staticmethod(self):
+ self.check_wrapper_attrs(staticmethod, '<staticmethod({!r})>')
+
+ def test_classmethod(self):
+ self.check_wrapper_attrs(classmethod, '<classmethod({!r})>')
def test_dotted(self):
decorators = MiscDecorators()