mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 22:44:27 +08:00
Fix the Python 2.7 tests
This commit is contained in:
@@ -5,7 +5,7 @@ import warnings
|
|||||||
from ..helpers import TestCase
|
from ..helpers import TestCase
|
||||||
from jedi import Script
|
from jedi import Script
|
||||||
from jedi import cache
|
from jedi import cache
|
||||||
from jedi._compatibility import is_py33
|
from jedi._compatibility import is_py33, py_version
|
||||||
|
|
||||||
|
|
||||||
def assert_signature(source, expected_name, expected_index=0, line=None, column=None):
|
def assert_signature(source, expected_name, expected_index=0, line=None, column=None):
|
||||||
@@ -324,8 +324,10 @@ def test_keyword_argument_index():
|
|||||||
def get(source, column=None):
|
def get(source, column=None):
|
||||||
return Script(source, column=column).call_signatures()[0]
|
return Script(source, column=column).call_signatures()[0]
|
||||||
|
|
||||||
assert get('sorted([], key=a').index == 1
|
# The signature of sorted changed from 2 to 3.
|
||||||
assert get('sorted([], key=').index == 1
|
py2_offset = int(py_version < 30)
|
||||||
|
assert get('sorted([], key=a').index == 1 + py2_offset
|
||||||
|
assert get('sorted([], key=').index == 1 + py2_offset
|
||||||
assert get('sorted([], no_key=a').index is None
|
assert get('sorted([], no_key=a').index is None
|
||||||
|
|
||||||
kw_func = 'def foo(a, b): pass\nfoo(b=3, a=4)'
|
kw_func = 'def foo(a, b): pass\nfoo(b=3, a=4)'
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
from textwrap import dedent
|
from textwrap import dedent
|
||||||
|
|
||||||
|
import pytest
|
||||||
from parso import parse
|
from parso import parse
|
||||||
|
|
||||||
import jedi
|
import jedi
|
||||||
|
from jedi._compatibility import py_version
|
||||||
|
|
||||||
|
|
||||||
def test_form_feed_characters():
|
def test_form_feed_characters():
|
||||||
@@ -86,7 +89,8 @@ def test_tokenizer_with_string_literal_backslash():
|
|||||||
assert c[0]._name._context.get_safe_value() == 'foo'
|
assert c[0]._name._context.get_safe_value() == 'foo'
|
||||||
|
|
||||||
|
|
||||||
def test_ellipsis():
|
@pytest.mark.skipif('py_version < 30', reason='In 2.7 Ellipsis can only be used like x[...]')
|
||||||
|
def test_ellipsis_without_getitem():
|
||||||
def_, = jedi.Script('x=...;x').goto_definitions()
|
def_, = jedi.Script('x=...;x').goto_definitions()
|
||||||
|
|
||||||
assert def_.name == 'ellipsis'
|
assert def_.name == 'ellipsis'
|
||||||
|
|||||||
Reference in New Issue
Block a user