More test_evaluate Script fixtures

This commit is contained in:
Dave Halter
2017-12-29 19:36:05 +01:00
parent 5fc755b0cf
commit bf73fcbed4
9 changed files with 89 additions and 100 deletions

View File

@@ -1,14 +1,12 @@
from textwrap import dedent
from jedi import Script
def get_definition_and_evaluator(source):
def get_definition_and_evaluator(Script, source):
first, = Script(dedent(source)).goto_definitions()
return first._name._context, first._evaluator
def test_function_execution():
def test_function_execution(Script):
"""
We've been having an issue of a mutable list that was changed inside the
function execution. Test if an execution always returns the same result.
@@ -18,7 +16,7 @@ def test_function_execution():
def x():
return str()
x"""
func, evaluator = get_definition_and_evaluator(s)
func, evaluator = get_definition_and_evaluator(Script, s)
# Now just use the internals of the result (easiest way to get a fully
# usable function).
# Should return the same result both times.
@@ -26,11 +24,11 @@ def test_function_execution():
assert len(func.execute_evaluated()) == 1
def test_class_mro():
def test_class_mro(Script):
s = """
class X(object):
pass
X"""
cls, evaluator = get_definition_and_evaluator(s)
cls, evaluator = get_definition_and_evaluator(Script, s)
mro = cls.py__mro__()
assert [c.name.string_name for c in mro] == ['X', 'object']