Remove the module path from the parser tree.

Some static analysis tests are still failing.
This commit is contained in:
Dave Halter
2017-03-27 18:13:32 +02:00
parent b60ec024fa
commit 8a35a04439
14 changed files with 102 additions and 101 deletions

View File

@@ -338,7 +338,7 @@ class TestGotoAssignments(TestCase):
n = nms[0].goto_assignments()[0]
assert n.name == 'json'
assert n.type == 'module'
assert n._name.tree_name.get_definition().type == 'file_input'
assert n._name._context.tree_node.type == 'file_input'
assert nms[1].name == 'foo'
assert nms[1].type == 'module'
@@ -347,7 +347,7 @@ class TestGotoAssignments(TestCase):
assert len(ass) == 1
assert ass[0].name == 'json'
assert ass[0].type == 'module'
assert ass[0]._name.tree_name.get_definition().type == 'file_input'
assert ass[0]._name._context.tree_node.type == 'file_input'
def test_added_equals_to_params():

View File

@@ -15,7 +15,7 @@ from ..helpers import cwd_at
def check_module_test(code):
grammar = load_grammar()
module_context = ModuleContext(Evaluator(grammar), parse(code))
module_context = ModuleContext(Evaluator(grammar), parse(code), path=None)
return _check_module(module_context)
@@ -68,7 +68,7 @@ def test_sys_path_with_modifications():
path = os.path.abspath(os.path.join(os.curdir, 'module_name.py'))
grammar = load_grammar()
module_node = parse(code, path=path)
module_context = ModuleContext(Evaluator(grammar), module_node)
module_context = ModuleContext(Evaluator(grammar), module_node, path=path)
paths = sys_path_with_modifications(module_context.evaluator, module_context)
assert '/tmp/.buildout/eggs/important_package.egg' in paths

View File

@@ -88,20 +88,6 @@ class TestImports():
assert imp.end_pos == (1, len('import math'))
def test_module():
module = parse('asdf', path='example.py')
name = module.name
assert str(name) == 'example'
assert name.start_pos == (1, 0)
assert name.end_pos == (1, 7)
module = parse('asdf')
name = module.name
assert str(name) == ''
assert name.start_pos == (1, 0)
assert name.end_pos == (1, 0)
def test_end_pos():
s = dedent('''
x = ['a', 'b', 'c']