diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2011-11-25 17:56:07 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2011-11-25 17:56:07 (GMT) |
commit | 86a36b500a7f7581194382ce4df914e4bb487873 (patch) | |
tree | 0d83f90f9a14d40d3559ae188c203e9c8941c6db /Lib/test/test_funcattrs.py | |
parent | 0e86a5842d0fadff37c299e8a1c03535c6727b19 (diff) | |
download | cpython-86a36b500a7f7581194382ce4df914e4bb487873.zip cpython-86a36b500a7f7581194382ce4df914e4bb487873.tar.gz cpython-86a36b500a7f7581194382ce4df914e4bb487873.tar.bz2 |
PEP 3155 / issue #13448: Qualified name for classes and functions.
Diffstat (limited to 'Lib/test/test_funcattrs.py')
-rw-r--r-- | Lib/test/test_funcattrs.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Lib/test/test_funcattrs.py b/Lib/test/test_funcattrs.py index 4d19368..f4a38b9 100644 --- a/Lib/test/test_funcattrs.py +++ b/Lib/test/test_funcattrs.py @@ -2,6 +2,15 @@ from test import support import types import unittest + +def global_function(): + def inner_function(): + class LocalClass: + pass + return LocalClass + return lambda: inner_function + + class FuncAttrsTest(unittest.TestCase): def setUp(self): class F: @@ -96,6 +105,24 @@ class FunctionPropertiesTest(FuncAttrsTest): self.assertEqual(self.fi.a.__name__, 'a') self.cannot_set_attr(self.fi.a, "__name__", 'a', AttributeError) + def test___qualname__(self): + # PEP 3155 + self.assertEqual(self.b.__qualname__, 'FuncAttrsTest.setUp.<locals>.b') + self.assertEqual(FuncAttrsTest.setUp.__qualname__, 'FuncAttrsTest.setUp') + self.assertEqual(global_function.__qualname__, 'global_function') + self.assertEqual(global_function().__qualname__, + 'global_function.<locals>.<lambda>') + self.assertEqual(global_function()().__qualname__, + 'global_function.<locals>.inner_function') + self.assertEqual(global_function()()().__qualname__, + 'global_function.<locals>.inner_function.<locals>.LocalClass') + self.b.__qualname__ = 'c' + self.assertEqual(self.b.__qualname__, 'c') + self.b.__qualname__ = 'd' + self.assertEqual(self.b.__qualname__, 'd') + # __qualname__ must be a string + self.cannot_set_attr(self.b, '__qualname__', 7, TypeError) + def test___code__(self): num_one, num_two = 7, 8 def a(): pass |