diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2011-12-23 11:40:16 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2011-12-23 11:40:16 (GMT) |
commit | 5b62942074f2f6ae57c0e1bd8e4993dff4f5997f (patch) | |
tree | bf3f323f4b84a51edae986f2fee3686cc2d4c9bd /Lib/test/test_funcattrs.py | |
parent | d22983d081845009e894dced4c4d835f18755520 (diff) | |
download | cpython-5b62942074f2f6ae57c0e1bd8e4993dff4f5997f.zip cpython-5b62942074f2f6ae57c0e1bd8e4993dff4f5997f.tar.gz cpython-5b62942074f2f6ae57c0e1bd8e4993dff4f5997f.tar.bz2 |
Issue #13577: Built-in methods and functions now have a __qualname__.
Patch by sbt.
Diffstat (limited to 'Lib/test/test_funcattrs.py')
-rw-r--r-- | Lib/test/test_funcattrs.py | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/Lib/test/test_funcattrs.py b/Lib/test/test_funcattrs.py index f4a38b9..c8ed830 100644 --- a/Lib/test/test_funcattrs.py +++ b/Lib/test/test_funcattrs.py @@ -342,11 +342,37 @@ class StaticMethodAttrsTest(unittest.TestCase): self.assertTrue(s.__func__ is f) +class BuiltinFunctionPropertiesTest(unittest.TestCase): + # XXX Not sure where this should really go since I can't find a + # test module specifically for builtin_function_or_method. + + def test_builtin__qualname__(self): + import time + + # builtin function: + self.assertEqual(len.__qualname__, 'len') + self.assertEqual(time.time.__qualname__, 'time') + + # builtin classmethod: + self.assertEqual(dict.fromkeys.__qualname__, 'dict.fromkeys') + self.assertEqual(float.__getformat__.__qualname__, + 'float.__getformat__') + + # builtin staticmethod: + self.assertEqual(str.maketrans.__qualname__, 'str.maketrans') + self.assertEqual(bytes.maketrans.__qualname__, 'bytes.maketrans') + + # builtin bound instance method: + self.assertEqual([1, 2, 3].append.__qualname__, 'list.append') + self.assertEqual({'foo': 'bar'}.pop.__qualname__, 'dict.pop') + + def test_main(): support.run_unittest(FunctionPropertiesTest, InstancemethodAttrTest, ArbitraryFunctionAttrTest, FunctionDictsTest, FunctionDocstringTest, CellTest, - StaticMethodAttrsTest) + StaticMethodAttrsTest, + BuiltinFunctionPropertiesTest) if __name__ == "__main__": test_main() |