summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_functools.py
diff options
context:
space:
mode:
authorMeador Inge <meadori@gmail.com>2011-12-12 04:37:31 (GMT)
committerMeador Inge <meadori@gmail.com>2011-12-12 04:37:31 (GMT)
commitff7f64ca0ee65ebb4db34132977da00b318c307c (patch)
tree61d8559907d1d0d8d8e2d0d4113f9bf27a30c142 /Lib/test/test_functools.py
parentbf6e560d0ccbe6bee4d835a15a8e8e098b9c7ef6 (diff)
downloadcpython-ff7f64ca0ee65ebb4db34132977da00b318c307c.zip
cpython-ff7f64ca0ee65ebb4db34132977da00b318c307c.tar.gz
cpython-ff7f64ca0ee65ebb4db34132977da00b318c307c.tar.bz2
Issue #13544: Add __qualname__ to functools.WRAPPER_ASSIGNMENTS.
Patch by Filip GruszczyƄski.
Diffstat (limited to 'Lib/test/test_functools.py')
-rw-r--r--Lib/test/test_functools.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py
index c4d9fe6..c4910a7 100644
--- a/Lib/test/test_functools.py
+++ b/Lib/test/test_functools.py
@@ -226,6 +226,7 @@ class TestUpdateWrapper(unittest.TestCase):
self.check_wrapper(wrapper, f)
self.assertIs(wrapper.__wrapped__, f)
self.assertEqual(wrapper.__name__, 'f')
+ self.assertEqual(wrapper.__qualname__, f.__qualname__)
self.assertEqual(wrapper.attr, 'This is also a test')
self.assertEqual(wrapper.__annotations__['a'], 'This is a new annotation')
self.assertNotIn('b', wrapper.__annotations__)
@@ -246,6 +247,7 @@ class TestUpdateWrapper(unittest.TestCase):
functools.update_wrapper(wrapper, f, (), ())
self.check_wrapper(wrapper, f, (), ())
self.assertEqual(wrapper.__name__, 'wrapper')
+ self.assertNotEqual(wrapper.__qualname__, f.__qualname__)
self.assertEqual(wrapper.__doc__, None)
self.assertEqual(wrapper.__annotations__, {})
self.assertFalse(hasattr(wrapper, 'attr'))
@@ -263,6 +265,7 @@ class TestUpdateWrapper(unittest.TestCase):
functools.update_wrapper(wrapper, f, assign, update)
self.check_wrapper(wrapper, f, assign, update)
self.assertEqual(wrapper.__name__, 'wrapper')
+ self.assertNotEqual(wrapper.__qualname__, f.__qualname__)
self.assertEqual(wrapper.__doc__, None)
self.assertEqual(wrapper.attr, 'This is a different test')
self.assertEqual(wrapper.dict_attr, f.dict_attr)
@@ -309,17 +312,18 @@ class TestWraps(TestUpdateWrapper):
def wrapper():
pass
self.check_wrapper(wrapper, f)
- return wrapper
+ return wrapper, f
def test_default_update(self):
- wrapper = self._default_update()
+ wrapper, f = self._default_update()
self.assertEqual(wrapper.__name__, 'f')
+ self.assertEqual(wrapper.__qualname__, f.__qualname__)
self.assertEqual(wrapper.attr, 'This is also a test')
@unittest.skipIf(not sys.flags.optimize <= 1,
"Docstrings are omitted with -O2 and above")
def test_default_update_doc(self):
- wrapper = self._default_update()
+ wrapper, _ = self._default_update()
self.assertEqual(wrapper.__doc__, 'This is a test')
def test_no_update(self):
@@ -332,6 +336,7 @@ class TestWraps(TestUpdateWrapper):
pass
self.check_wrapper(wrapper, f, (), ())
self.assertEqual(wrapper.__name__, 'wrapper')
+ self.assertNotEqual(wrapper.__qualname__, f.__qualname__)
self.assertEqual(wrapper.__doc__, None)
self.assertFalse(hasattr(wrapper, 'attr'))
@@ -351,6 +356,7 @@ class TestWraps(TestUpdateWrapper):
pass
self.check_wrapper(wrapper, f, assign, update)
self.assertEqual(wrapper.__name__, 'wrapper')
+ self.assertNotEqual(wrapper.__qualname__, f.__qualname__)
self.assertEqual(wrapper.__doc__, None)
self.assertEqual(wrapper.attr, 'This is a different test')
self.assertEqual(wrapper.dict_attr, f.dict_attr)