forked from VimPlug/jedi
Restructure namedtuple tests a bit.
This commit is contained in:
@@ -2,6 +2,8 @@
|
|||||||
Tests of various stdlib related things that could not be tested
|
Tests of various stdlib related things that could not be tested
|
||||||
with "Black Box Tests".
|
with "Black Box Tests".
|
||||||
"""
|
"""
|
||||||
|
from textwrap import dedent
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from jedi import Script
|
from jedi import Script
|
||||||
from jedi._compatibility import is_py26
|
from jedi._compatibility import is_py26
|
||||||
@@ -16,10 +18,11 @@ pytestmark = pytest.mark.skipif('sys.version_info[0] < 3')
|
|||||||
('s', ['smart']),
|
('s', ['smart']),
|
||||||
])
|
])
|
||||||
def test_namedtuple_str(letter, expected):
|
def test_namedtuple_str(letter, expected):
|
||||||
source = "import collections\n" + \
|
source = dedent("""\
|
||||||
"Person = collections.namedtuple('Person', 'name smart')\n" + \
|
import collections
|
||||||
"dave = Person('Dave', False)\n" + \
|
Person = collections.namedtuple('Person', 'name smart')
|
||||||
"dave.%s" % letter
|
dave = Person('Dave', False)
|
||||||
|
dave.%s""") % letter
|
||||||
result = Script(source).completions()
|
result = Script(source).completions()
|
||||||
completions = set(r.name for r in result)
|
completions = set(r.name for r in result)
|
||||||
if is_py26:
|
if is_py26:
|
||||||
@@ -29,10 +32,11 @@ def test_namedtuple_str(letter, expected):
|
|||||||
|
|
||||||
|
|
||||||
def test_namedtuple_list():
|
def test_namedtuple_list():
|
||||||
source = "import collections\n" + \
|
source = dedent("""\
|
||||||
"Cat = collections.namedtuple('Person', ['legs', u'length', 'large'])\n" + \
|
import collections
|
||||||
"garfield = Cat(4, '85cm', True)\n" + \
|
Cat = collections.namedtuple('Person', ['legs', u'length', 'large'])
|
||||||
"garfield.l"
|
garfield = Cat(4, '85cm', True)
|
||||||
|
garfield.l""")
|
||||||
result = Script(source).completions()
|
result = Script(source).completions()
|
||||||
completions = set(r.name for r in result)
|
completions = set(r.name for r in result)
|
||||||
if is_py26:
|
if is_py26:
|
||||||
|
|||||||
Reference in New Issue
Block a user