summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <cpopa@cloudbasesolutions.com>2015-06-15 15:01:08 +0300
committerClaudiu Popa <cpopa@cloudbasesolutions.com>2015-06-15 15:01:08 +0300
commite0d56873c5a8837ca8c11346db368dd33bdab42e (patch)
tree832dfb9c2c7bde090baa95075060da3c9b5dafdd
parent9dae9fed0713625183ed1c780f93b0023fac92e1 (diff)
downloadastroid-git-e0d56873c5a8837ca8c11346db368dd33bdab42e.tar.gz
Staticmethods retrieved with super are functions, not bound methods.
-rw-r--r--astroid/objects.py2
-rw-r--r--astroid/tests/unittest_objects.py6
2 files changed, 7 insertions, 1 deletions
diff --git a/astroid/objects.py b/astroid/objects.py
index b0a3e6c1..a1c1da10 100644
--- a/astroid/objects.py
+++ b/astroid/objects.py
@@ -170,7 +170,7 @@ class Super(NodeNG):
yield BoundMethod(infered, cls)
elif self._scope.type == 'classmethod' and infered.type == 'method':
yield infered
- elif self._class_based:
+ elif self._class_based or infered.type == 'staticmethod':
yield infered
else:
yield BoundMethod(infered, cls)
diff --git a/astroid/tests/unittest_objects.py b/astroid/tests/unittest_objects.py
index 24844291..51a0acb0 100644
--- a/astroid/tests/unittest_objects.py
+++ b/astroid/tests/unittest_objects.py
@@ -372,6 +372,8 @@ class SuperTests(unittest.TestCase):
class A(object):
def spam(self): return "A"
def foo(self): return "A"
+ @staticmethod
+ def static(self): pass
class B(A):
def boo(self): return "B"
def spam(self): return "B"
@@ -383,6 +385,7 @@ class SuperTests(unittest.TestCase):
super(C, self).boo #@
super(E, self).spam #@
super(E, self).foo #@
+ super(E, self).static #@
''')
first = next(ast_nodes[0].infer())
self.assertIsInstance(first, bases.BoundMethod)
@@ -395,6 +398,9 @@ class SuperTests(unittest.TestCase):
self.assertEqual(third.bound.name, 'B')
fourth = next(ast_nodes[3].infer())
self.assertEqual(fourth.bound.name, 'A')
+ static = next(ast_nodes[4].infer())
+ self.assertIsInstance(static, nodes.Function)
+ self.assertEqual(static.parent.scope().name, 'A')
def test_super_data_model(self):
ast_nodes = test_utils.extract_node('''