diff options
| author | Claudiu Popa <pcmanticore@gmail.com> | 2014-05-07 17:14:48 +0300 |
|---|---|---|
| committer | Claudiu Popa <pcmanticore@gmail.com> | 2014-05-07 17:14:48 +0300 |
| commit | cd08d8724ec41f4630b143a62f0d4e5479ab0607 (patch) | |
| tree | 436e1040e9de8e5f9f4dc58aa72dce1811deac9a /test | |
| parent | b13ef13e8365348b957e77105fdeeeb5bde69c49 (diff) | |
| download | astroid-git-cd08d8724ec41f4630b143a62f0d4e5479ab0607.tar.gz | |
Function nodes can detect if they are decorated with subclasses of builtin descriptors when determining their type (`classmethod` and `staticmethod`).
--HG--
branch : classmethod_subclasses
Diffstat (limited to 'test')
| -rw-r--r-- | test/unittest_scoped_nodes.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/unittest_scoped_nodes.py b/test/unittest_scoped_nodes.py index 6c56c55f..4d0bc594 100644 --- a/test/unittest_scoped_nodes.py +++ b/test/unittest_scoped_nodes.py @@ -380,6 +380,37 @@ test() self.assertIsInstance(one, nodes.Const) self.assertEqual(one.value, 1) + def test_type_builtin_descriptor_subclasses(self): + astroid = abuilder.string_build(dedent(""" + class classonlymethod(classmethod): + pass + class staticonlymethod(staticmethod): + pass + + class Node: + @classonlymethod + def clsmethod_subclass(cls): + pass + @classmethod + def clsmethod(cls): + pass + @staticonlymethod + def staticmethod_subclass(cls): + pass + @staticmethod + def stcmethod(cls): + pass + """)) + node = astroid.locals['Node'][0] + self.assertEqual(node.locals['clsmethod_subclass'][0].type, + 'classmethod') + self.assertEqual(node.locals['clsmethod'][0].type, + 'classmethod') + self.assertEqual(node.locals['staticmethod_subclass'][0].type, + 'staticmethod') + self.assertEqual(node.locals['stcmethod'][0].type, + 'staticmethod') + class ClassNodeTC(TestCase): |
