1
0
forked from VimPlug/jedi

Remove most version_info.major usages

This commit is contained in:
Dave Halter
2020-07-02 03:00:01 +02:00
parent 188fdcd34f
commit 6e184bca97
16 changed files with 26 additions and 95 deletions

View File

@@ -9,9 +9,6 @@ def test_simple_annotations(Script, environment):
If annotations adhere to PEP-0484, we use them (they override inference),
else they are parsed but ignored
"""
if environment.version_info.major == 2:
pytest.skip()
source = dedent("""\
def annot(a:3):
return a
@@ -45,18 +42,12 @@ def test_simple_annotations(Script, environment):
r'1\n'
])
def test_illegal_forward_references(Script, environment, reference):
if environment.version_info.major == 2:
pytest.skip()
source = 'def foo(bar: "%s"): bar' % reference
assert not Script(source).infer()
def test_lambda_forward_references(Script, environment):
if environment.version_info.major == 2:
pytest.skip()
source = 'def foo(bar: "lambda: 3"): bar'
# For now just receiving the 3 is ok. I'm doubting that this is what we

View File

@@ -16,11 +16,7 @@ def test_simple(inference_state, environment):
upper, = obj.py__getattribute__(u'upper')
objs = list(upper.execute_with_values())
assert len(objs) == 1
if environment.version_info.major == 2:
expected = 'unicode'
else:
expected = 'str'
assert objs[0].name.string_name == expected
assert objs[0].name.string_name == 'str'
def test_builtin_loading(inference_state):
@@ -65,13 +61,9 @@ def test_string_literals(Script, environment):
assert typ('""') == 'str'
assert typ('r""') == 'str'
if environment.version_info.major > 2:
assert typ('br""') == 'bytes'
assert typ('b""') == 'bytes'
assert typ('u""') == 'str'
else:
assert typ('b""') == 'str'
assert typ('u""') == 'unicode'
assert typ('br""') == 'bytes'
assert typ('b""') == 'bytes'
assert typ('u""') == 'str'
def test_method_completion(Script, environment):
@@ -94,9 +86,6 @@ def test_time_docstring(Script):
def test_dict_values(Script, environment):
if environment.version_info.major == 2:
# It looks like typeshed for Python 2 returns Any.
pytest.skip()
assert Script('import sys\nsys.modules["alshdb;lasdhf"]').infer()

View File

@@ -103,11 +103,8 @@ def test_sys_getwindowsversion(Script, environment):
# This should only exist on Windows, but type inference should happen
# everywhere.
definitions = Script('import sys; sys.getwindowsversion().major').infer()
if environment.version_info.major == 2:
assert not definitions
else:
def_, = definitions
assert def_.name == 'int'
def_, = definitions
assert def_.name == 'int'
def test_sys_hexversion(Script):

View File

@@ -10,8 +10,6 @@ import pytest
pytest.param('... == ...', marks=pytest.mark.xfail),
])
def test_equals(Script, environment, source):
if environment.version_info.major < 3:
pytest.skip("Ellipsis does not exists in 2")
script = Script(source)
node = script._module_node.children[0]
first, = script._get_module_context().infer_node(node)

View File

@@ -90,14 +90,8 @@ def test_re_sub(Script, environment):
return {d.name for d in defs}
names = run("import re; re.sub('a', 'a', 'f')")
if environment.version_info.major == 2:
assert names == {'str'}
else:
assert names == {'str'}
assert names == {'str'}
# This param is missing because of overloading.
names = run("import re; re.sub('a', 'a')")
if environment.version_info.major == 2:
assert names == {'str', 'unicode'}
else:
assert names == {'str', 'bytes'}
assert names == {'str', 'bytes'}