Add a Definition.is_definition function to be able to check if a name is a definition or not.

This commit is contained in:
Dave Halter
2014-09-08 23:44:35 +02:00
parent 851717a968
commit 0dcb91d236
3 changed files with 27 additions and 8 deletions

View File

@@ -200,8 +200,11 @@ class TestGotoAssignments(TestCase):
function. They are not really different in functionality, but really
different as an implementation.
"""
def test_basic(self):
refs = names('a = 1; a', references=True, definitions=False)
assert len(refs) == 1
ass = refs[0].goto_assignments()
assert ass[0].description == ''
def test_repetition(self):
defs = names('a = 1; a', references=True, definitions=False)
# Repeat on the same variable. Shouldn't change once we're on a
# definition.
for _ in range(3):
assert len(defs) == 1
ass = defs[0].goto_assignments()
assert ass[0].description == 'a = 1'