mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-10 07:41:51 +08:00
Remove most version_info.major usages
This commit is contained in:
@@ -337,9 +337,7 @@ def test_fuzzy_completion(Script):
|
||||
|
||||
def test_math_fuzzy_completion(Script, environment):
|
||||
script = Script('import math\nmath.og')
|
||||
expected = ['copysign', 'log', 'log10', 'log1p']
|
||||
if environment.version_info.major >= 3:
|
||||
expected.append('log2')
|
||||
expected = ['copysign', 'log', 'log10', 'log1p', 'log2']
|
||||
completions = script.complete(fuzzy=True)
|
||||
assert expected == [comp.name for comp in completions]
|
||||
for c in completions:
|
||||
|
||||
@@ -36,10 +36,7 @@ def test_follow_import_incomplete(Script, environment):
|
||||
|
||||
# incomplete `from * import` part
|
||||
datetime = check_follow_definition_types(Script, "from datetime import datetim")
|
||||
if environment.version_info.major == 2:
|
||||
assert datetime == ['class']
|
||||
else:
|
||||
assert set(datetime) == {'class', 'instance'} # py3: builtin and pure py version
|
||||
assert set(datetime) == {'class', 'instance'} # py3: builtin and pure py version
|
||||
# os.path check
|
||||
ospath = check_follow_definition_types(Script, "from os.path import abspat")
|
||||
assert set(ospath) == {'function'}
|
||||
|
||||
@@ -125,7 +125,7 @@ def test_get_signatures_whitespace(Script):
|
||||
abs(
|
||||
def x():
|
||||
pass
|
||||
""")
|
||||
""") # noqa
|
||||
assert_signature(Script, s, 'abs', 0, line=1, column=5)
|
||||
|
||||
|
||||
@@ -239,13 +239,12 @@ def test_complex(Script, environment):
|
||||
func1, = sig1._name.infer()
|
||||
func2, = sig2._name.infer()
|
||||
|
||||
if environment.version_info.major == 3:
|
||||
# Do these checks just for Python 3, I'm too lazy to deal with this
|
||||
# legacy stuff. ~ dave.
|
||||
assert get_signature(func1.tree_node) \
|
||||
== 'compile(pattern: AnyStr, flags: _FlagsType = ...) -> Pattern[AnyStr]'
|
||||
assert get_signature(func2.tree_node) \
|
||||
== 'compile(pattern: Pattern[AnyStr], flags: _FlagsType = ...) ->\nPattern[AnyStr]'
|
||||
# Do these checks just for Python 3, I'm too lazy to deal with this
|
||||
# legacy stuff. ~ dave.
|
||||
assert get_signature(func1.tree_node) \
|
||||
== 'compile(pattern: AnyStr, flags: _FlagsType = ...) -> Pattern[AnyStr]'
|
||||
assert get_signature(func2.tree_node) \
|
||||
== 'compile(pattern: Pattern[AnyStr], flags: _FlagsType = ...) ->\nPattern[AnyStr]'
|
||||
|
||||
# jedi-vim #70
|
||||
s = """def foo("""
|
||||
@@ -373,10 +372,8 @@ def test_keyword_argument_index(Script, environment):
|
||||
def get(source, column=None):
|
||||
return Script(source).get_signatures(column=column)[0]
|
||||
|
||||
# The signature of sorted changed from 2 to 3.
|
||||
py2_offset = int(environment.version_info.major == 2)
|
||||
assert get('sorted([], key=a').index == 1 + py2_offset
|
||||
assert get('sorted([], key=').index == 1 + py2_offset
|
||||
assert get('sorted([], key=a').index == 1
|
||||
assert get('sorted([], key=').index == 1
|
||||
assert get('sorted([], no_key=a').index is None
|
||||
|
||||
kw_func = 'def foo(a, b): pass\nfoo(b=3, a=4)'
|
||||
|
||||
@@ -46,9 +46,6 @@ class TestFullNameWithGotoDefinitions(MixinTestFullName, TestCase):
|
||||
operation = 'infer'
|
||||
|
||||
def test_tuple_mapping(self):
|
||||
if self.environment.version_info.major == 2:
|
||||
pytest.skip('Python 2 also yields None.')
|
||||
|
||||
self.check("""
|
||||
import re
|
||||
any_re = re.compile('.*')
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
Test of keywords and ``jedi.keywords``
|
||||
"""
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
def test_goto_keyword(Script):
|
||||
"""
|
||||
@@ -17,10 +15,7 @@ def test_goto_keyword(Script):
|
||||
def test_keyword(Script, environment):
|
||||
""" github jedi-vim issue #44 """
|
||||
defs = Script("print").infer()
|
||||
if environment.version_info.major < 3:
|
||||
assert defs == []
|
||||
else:
|
||||
assert [d.docstring() for d in defs]
|
||||
assert [d.docstring() for d in defs]
|
||||
|
||||
assert Script("import").goto() == []
|
||||
|
||||
@@ -51,10 +46,6 @@ def test_keyword_attributes(Script):
|
||||
|
||||
|
||||
def test_none_keyword(Script, environment):
|
||||
if environment.version_info.major == 2:
|
||||
# Just don't care about Python 2 anymore, it's almost gone.
|
||||
pytest.skip()
|
||||
|
||||
none, = Script('None').complete()
|
||||
assert not none.docstring()
|
||||
assert none.name == 'None'
|
||||
|
||||
Reference in New Issue
Block a user