summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_functools.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2010-08-08 00:56:52 (GMT)
committerRaymond Hettinger <python@rcn.com>2010-08-08 00:56:52 (GMT)
commitc6d80c1bef62c996d1a7d3b544a108fef17fbf65 (patch)
tree69bfd207498ceb86fcec365e074c50c0f752e5fc /Lib/test/test_functools.py
parentf56c9cd30d7b7113e32a2562f66cc78a3ec441a3 (diff)
downloadcpython-c6d80c1bef62c996d1a7d3b544a108fef17fbf65.zip
cpython-c6d80c1bef62c996d1a7d3b544a108fef17fbf65.tar.gz
cpython-c6d80c1bef62c996d1a7d3b544a108fef17fbf65.tar.bz2
Issue 8814: functools.wraps() did not copy __annotations__.
Diffstat (limited to 'Lib/test/test_functools.py')
-rw-r--r--Lib/test/test_functools.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py
index eff31e0..7b79f28 100644
--- a/Lib/test/test_functools.py
+++ b/Lib/test/test_functools.py
@@ -181,17 +181,19 @@ class TestUpdateWrapper(unittest.TestCase):
self.assertTrue(wrapped_attr[key] is wrapper_attr[key])
def test_default_update(self):
- def f():
+ def f(a:'This is a new annotation'):
"""This is a test"""
pass
f.attr = 'This is also a test'
- def wrapper():
+ def wrapper(b:'This is the prior annotation'):
pass
functools.update_wrapper(wrapper, f)
self.check_wrapper(wrapper, f)
self.assertEqual(wrapper.__name__, 'f')
self.assertEqual(wrapper.__doc__, 'This is a test')
self.assertEqual(wrapper.attr, 'This is also a test')
+ self.assertEqual(wrapper.__annotations__['a'], 'This is a new annotation')
+ self.assertNotIn('b', wrapper.__annotations__)
def test_no_update(self):
def f():
@@ -204,6 +206,7 @@ class TestUpdateWrapper(unittest.TestCase):
self.check_wrapper(wrapper, f, (), ())
self.assertEqual(wrapper.__name__, 'wrapper')
self.assertEqual(wrapper.__doc__, None)
+ self.assertEqual(wrapper.__annotations__, {})
self.assertFalse(hasattr(wrapper, 'attr'))
def test_selective_update(self):
@@ -230,6 +233,7 @@ class TestUpdateWrapper(unittest.TestCase):
functools.update_wrapper(wrapper, max)
self.assertEqual(wrapper.__name__, 'max')
self.assertTrue(wrapper.__doc__.startswith('max('))
+ self.assertEqual(wrapper.__annotations__, {})
class TestWraps(TestUpdateWrapper):