More Script fixture conversions in test_evaluate

This commit is contained in:
Dave Halter
2017-12-29 19:08:09 +01:00
parent 2493e6ea16
commit ac21fc376e
6 changed files with 37 additions and 45 deletions

View File

@@ -1,16 +1,16 @@
from textwrap import dedent
import jedi
import pytest
@pytest.mark.skipif('sys.version_info[0] < 3')
def test_simple_annotations():
def test_simple_annotations(Script, environment):
"""
Annotations only exist in Python 3.
If annotations adhere to PEP-0484, we use them (they override inference),
else they are parsed but ignored
"""
if environment.version_info.major == 2:
pytest.skip()
source = dedent("""\
def annot(a:3):
@@ -18,7 +18,7 @@ def test_simple_annotations():
annot('')""")
assert [d.name for d in jedi.Script(source, ).goto_definitions()] == ['str']
assert [d.name for d in Script(source).goto_definitions()] == ['str']
source = dedent("""\
@@ -26,7 +26,7 @@ def test_simple_annotations():
return a
annot_ret('')""")
assert [d.name for d in jedi.Script(source, ).goto_definitions()] == ['str']
assert [d.name for d in Script(source).goto_definitions()] == ['str']
source = dedent("""\
def annot(a:int):
@@ -34,10 +34,9 @@ def test_simple_annotations():
annot('')""")
assert [d.name for d in jedi.Script(source, ).goto_definitions()] == ['int']
assert [d.name for d in Script(source).goto_definitions()] == ['int']
@pytest.mark.skipif('sys.version_info[0] < 3')
@pytest.mark.parametrize('reference', [
'assert 1',
'1',
@@ -45,16 +44,21 @@ def test_simple_annotations():
'1, 2',
r'1\n'
])
def test_illegal_forward_references(reference):
def test_illegal_forward_references(Script, environment, reference):
if environment.version_info.major == 2:
pytest.skip()
source = 'def foo(bar: "%s"): bar' % reference
assert not jedi.Script(source).goto_definitions()
assert not Script(source).goto_definitions()
@pytest.mark.skipif('sys.version_info[0] < 3')
def test_lambda_forward_references():
def test_lambda_forward_references(Script, environment):
if environment.version_info.major == 2:
pytest.skip()
source = 'def foo(bar: "lambda: 3"): bar'
# For now just receiving the 3 is ok. I'm doubting that this is what we
# want. We also execute functions. Should we only execute classes?
assert jedi.Script(source).goto_definitions()
assert Script(source).goto_definitions()