Use grammar in test scripts.

This commit is contained in:
Dave Halter
2014-12-07 18:22:11 +01:00
parent 6058855dd3
commit eead122636
3 changed files with 19 additions and 15 deletions

View File

@@ -6,7 +6,7 @@ from jedi.evaluate.sys_path import (_get_parent_dir_with_file,
_get_buildout_scripts,
_check_module)
from jedi.evaluate import Evaluator
from jedi.parser import Parser
from jedi.parser import Parser, load_grammar
from ..helpers import cwd_at
@@ -35,8 +35,9 @@ def test_append_on_non_sys_path():
d = Dummy()
d.path.append('foo')"""))
p = Parser(SRC)
paths = _check_module(Evaluator(), p.module)
grammar = load_grammar()
p = Parser(grammar, SRC)
paths = _check_module(Evaluator(grammar), p.module)
assert len(paths) > 0
assert 'foo' not in paths
@@ -45,8 +46,9 @@ def test_path_from_invalid_sys_path_assignment():
SRC = dedent(u("""
import sys
sys.path = 'invalid'"""))
p = Parser(SRC)
paths = _check_module(Evaluator(), p.module)
grammar = load_grammar()
p = Parser(grammar, SRC)
paths = _check_module(Evaluator(grammar), p.module)
assert len(paths) > 0
assert 'invalid' not in paths
@@ -67,7 +69,8 @@ def test_path_from_sys_path_assignment():
if __name__ == '__main__':
sys.exit(important_package.main())"""))
p = Parser(SRC)
paths = _check_module(Evaluator(), p.module)
grammar = load_grammar()
p = Parser(grammar, SRC)
paths = _check_module(Evaluator(grammar), p.module)
assert 1 not in paths
assert '/home/test/.buildout/eggs/important_package.egg' in paths