mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +08:00
stdlib fixture conversions
This commit is contained in:
@@ -5,19 +5,22 @@ with "Black Box Tests".
|
|||||||
from textwrap import dedent
|
from textwrap import dedent
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from jedi import Script
|
|
||||||
from jedi._compatibility import is_py26
|
from jedi._compatibility import is_py26
|
||||||
|
|
||||||
|
|
||||||
# The namedtuple is different for different Python2.7 versions. Some versions
|
# The namedtuple is different for different Python2.7 versions. Some versions
|
||||||
# are missing the attribute `_class_template`.
|
# 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'], [
|
@pytest.mark.parametrize(['letter', 'expected'], [
|
||||||
('n', ['name']),
|
('n', ['name']),
|
||||||
('s', ['smart']),
|
('s', ['smart']),
|
||||||
])
|
])
|
||||||
def test_namedtuple_str(letter, expected):
|
def test_namedtuple_str(letter, expected, Script):
|
||||||
source = dedent("""\
|
source = dedent("""\
|
||||||
import collections
|
import collections
|
||||||
Person = collections.namedtuple('Person', 'name smart')
|
Person = collections.namedtuple('Person', 'name smart')
|
||||||
@@ -31,7 +34,7 @@ def test_namedtuple_str(letter, expected):
|
|||||||
assert completions == set(expected)
|
assert completions == set(expected)
|
||||||
|
|
||||||
|
|
||||||
def test_namedtuple_list():
|
def test_namedtuple_list(Script):
|
||||||
source = dedent("""\
|
source = dedent("""\
|
||||||
import collections
|
import collections
|
||||||
Cat = collections.namedtuple('Person', ['legs', u'length', 'large'])
|
Cat = collections.namedtuple('Person', ['legs', u'length', 'large'])
|
||||||
@@ -45,7 +48,7 @@ def test_namedtuple_list():
|
|||||||
assert completions == set(['legs', 'length', 'large'])
|
assert completions == set(['legs', 'length', 'large'])
|
||||||
|
|
||||||
|
|
||||||
def test_namedtuple_content():
|
def test_namedtuple_content(Script):
|
||||||
source = dedent("""\
|
source = dedent("""\
|
||||||
import collections
|
import collections
|
||||||
Foo = collections.namedtuple('Foo', ['bar', 'baz'])
|
Foo = collections.namedtuple('Foo', ['bar', 'baz'])
|
||||||
@@ -63,7 +66,7 @@ def test_namedtuple_content():
|
|||||||
assert d(source + 'named.baz') == 'int'
|
assert d(source + 'named.baz') == 'int'
|
||||||
|
|
||||||
|
|
||||||
def test_nested_namedtuples():
|
def test_nested_namedtuples(Script):
|
||||||
"""
|
"""
|
||||||
From issue #730.
|
From issue #730.
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -5,10 +5,9 @@ import sys
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from jedi.evaluate import sys_path
|
from jedi.evaluate import sys_path
|
||||||
from jedi import Script
|
|
||||||
|
|
||||||
|
|
||||||
def test_paths_from_assignment():
|
def test_paths_from_assignment(Script):
|
||||||
def paths(src):
|
def paths(src):
|
||||||
script = Script(src, path='/foo/bar.py')
|
script = Script(src, path='/foo/bar.py')
|
||||||
expr_stmt = script._get_module_node().children[0]
|
expr_stmt = script._get_module_node().children[0]
|
||||||
|
|||||||
Reference in New Issue
Block a user