stdlib fixture conversions

This commit is contained in:
Dave Halter
2017-12-29 19:13:15 +01:00
parent ac21fc376e
commit 5fc755b0cf
2 changed files with 10 additions and 8 deletions

View File

@@ -5,19 +5,22 @@ with "Black Box Tests".
from textwrap import dedent
import pytest
from jedi import Script
from jedi._compatibility import is_py26
# The namedtuple is different for different Python2.7 versions. Some versions
# are missing the attribute `_class_template`.
pytestmark = pytest.mark.skipif('sys.version_info[0] < 3')
@pytest.fixture(autouse=True)
def skipping(environment):
if environment.version_info.major < 3:
pytest.skip()
@pytest.mark.parametrize(['letter', 'expected'], [
('n', ['name']),
('s', ['smart']),
])
def test_namedtuple_str(letter, expected):
def test_namedtuple_str(letter, expected, Script):
source = dedent("""\
import collections
Person = collections.namedtuple('Person', 'name smart')
@@ -31,7 +34,7 @@ def test_namedtuple_str(letter, expected):
assert completions == set(expected)
def test_namedtuple_list():
def test_namedtuple_list(Script):
source = dedent("""\
import collections
Cat = collections.namedtuple('Person', ['legs', u'length', 'large'])
@@ -45,7 +48,7 @@ def test_namedtuple_list():
assert completions == set(['legs', 'length', 'large'])
def test_namedtuple_content():
def test_namedtuple_content(Script):
source = dedent("""\
import collections
Foo = collections.namedtuple('Foo', ['bar', 'baz'])
@@ -63,7 +66,7 @@ def test_namedtuple_content():
assert d(source + 'named.baz') == 'int'
def test_nested_namedtuples():
def test_nested_namedtuples(Script):
"""
From issue #730.
"""

View File

@@ -5,10 +5,9 @@ import sys
import pytest
from jedi.evaluate import sys_path
from jedi import Script
def test_paths_from_assignment():
def test_paths_from_assignment(Script):
def paths(src):
script = Script(src, path='/foo/bar.py')
expr_stmt = script._get_module_node().children[0]