diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2011-12-12 12:47:25 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2011-12-12 12:47:25 (GMT) |
commit | 9d57481f043cb9b94bfc45c1ee041415d915cf8a (patch) | |
tree | 4806f5aa23aa5f72bf9cafe2e1b438d69ccb1f51 /Lib | |
parent | 16e6a80923db90031a50790613ef3673b30886d2 (diff) | |
download | cpython-9d57481f043cb9b94bfc45c1ee041415d915cf8a.zip cpython-9d57481f043cb9b94bfc45c1ee041415d915cf8a.tar.gz cpython-9d57481f043cb9b94bfc45c1ee041415d915cf8a.tar.bz2 |
Issue #13577: various kinds of descriptors now have a __qualname__ attribute.
Patch by sbt.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_descr.py | 18 | ||||
-rw-r--r-- | Lib/test/test_sys.py | 8 |
2 files changed, 22 insertions, 4 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index 4a7a9d2..2b2026c 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -4442,6 +4442,24 @@ order (MRO) for bases """ self.assertIn("can't delete X.__doc__", str(cm.exception)) self.assertEqual(X.__doc__, "banana") + def test_qualname(self): + descriptors = [str.lower, complex.real, float.real, int.__add__] + types = ['method', 'member', 'getset', 'wrapper'] + + # make sure we have an example of each type of descriptor + for d, n in zip(descriptors, types): + self.assertEqual(type(d).__name__, n + '_descriptor') + + for d in descriptors: + qualname = d.__objclass__.__qualname__ + '.' + d.__name__ + self.assertEqual(d.__qualname__, qualname) + + self.assertEqual(str.lower.__qualname__, 'str.lower') + self.assertEqual(complex.real.__qualname__, 'complex.real') + self.assertEqual(float.real.__qualname__, 'float.real') + self.assertEqual(int.__add__.__qualname__, 'int.__add__') + + class DictProxyTests(unittest.TestCase): def setUp(self): class C(object): diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py index 3169f67..f89514f 100644 --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -670,17 +670,17 @@ class SizeofTest(unittest.TestCase): # complex check(complex(0,1), size(h + '2d')) # method_descriptor (descriptor object) - check(str.lower, size(h + '2PP')) + check(str.lower, size(h + '3PP')) # classmethod_descriptor (descriptor object) # XXX # member_descriptor (descriptor object) import datetime - check(datetime.timedelta.days, size(h + '2PP')) + check(datetime.timedelta.days, size(h + '3PP')) # getset_descriptor (descriptor object) import collections - check(collections.defaultdict.default_factory, size(h + '2PP')) + check(collections.defaultdict.default_factory, size(h + '3PP')) # wrapper_descriptor (descriptor object) - check(int.__add__, size(h + '2P2P')) + check(int.__add__, size(h + '3P2P')) # method-wrapper (descriptor object) check({}.__iter__, size(h + '2P')) # dict |