mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 22:14:27 +08:00
Remove a lot of test references to Python 2/3.5
This commit is contained in:
22
conftest.py
22
conftest.py
@@ -1,7 +1,6 @@
|
||||
import tempfile
|
||||
import shutil
|
||||
import os
|
||||
import sys
|
||||
from functools import partial
|
||||
|
||||
import pytest
|
||||
@@ -18,9 +17,6 @@ collect_ignore = [
|
||||
'build/',
|
||||
'test/examples',
|
||||
]
|
||||
if sys.version_info < (3, 6):
|
||||
# Python 2 not supported syntax
|
||||
collect_ignore.append('test/test_inference/test_mixed.py')
|
||||
|
||||
|
||||
# The following hooks (pytest_configure, pytest_unconfigure) are used
|
||||
@@ -45,7 +41,7 @@ def pytest_addoption(parser):
|
||||
help="Warnings are treated as errors.")
|
||||
|
||||
parser.addoption("--env", action='store',
|
||||
help="Execute the tests in that environment (e.g. 35 for python3.5).")
|
||||
help="Execute the tests in that environment (e.g. 39 for python3.9).")
|
||||
parser.addoption("--interpreter-env", "-I", action='store_true',
|
||||
help="Don't use subprocesses to guarantee having safe "
|
||||
"code execution. Useful for debugging.")
|
||||
@@ -180,19 +176,3 @@ def skip_pre_python37(environment):
|
||||
# This if is just needed to avoid that tests ever skip way more than
|
||||
# they should for all Python versions.
|
||||
pytest.skip()
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def skip_pre_python35(environment):
|
||||
if environment.version_info < (3, 5):
|
||||
# This if is just needed to avoid that tests ever skip way more than
|
||||
# they should for all Python versions.
|
||||
pytest.skip()
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def skip_pre_python36(environment):
|
||||
if environment.version_info < (3, 6):
|
||||
# This if is just needed to avoid that tests ever skip way more than
|
||||
# they should for all Python versions.
|
||||
pytest.skip()
|
||||
|
||||
@@ -272,9 +272,6 @@ dic = {str(key): ''}
|
||||
#? str()
|
||||
dic['']
|
||||
|
||||
# Just skip Python 2 tests from here. EoL soon, I'm too lazy for it.
|
||||
# python > 2.7
|
||||
|
||||
|
||||
for x in {1: 3.0, '': 1j}:
|
||||
#? int() str()
|
||||
@@ -473,7 +470,6 @@ def test_func():
|
||||
#? int()
|
||||
tuple({1})[0]
|
||||
|
||||
# python > 2.7
|
||||
# -----------------
|
||||
# PEP 3132 Extended Iterable Unpacking (star unpacking)
|
||||
# -----------------
|
||||
|
||||
@@ -5,8 +5,6 @@ Currently we're not supporting completion of them, but they should at least not
|
||||
raise errors or return extremely strange results.
|
||||
"""
|
||||
|
||||
# python >= 3.5
|
||||
|
||||
async def x():
|
||||
return 1
|
||||
|
||||
|
||||
@@ -344,8 +344,6 @@ def foo(my_t=some_defa
|
||||
#? ['some_default']
|
||||
def foo(my_t=some_defa, my_t2=some_defa
|
||||
|
||||
# python > 2.7
|
||||
|
||||
#? ['my_type']
|
||||
def foo(my_t: lala=some_defa, my_t2: my_typ
|
||||
#? ['my_type']
|
||||
|
||||
@@ -382,7 +382,6 @@ getattr(getattr, 1)
|
||||
getattr(str, [])
|
||||
|
||||
|
||||
# python >= 3.5
|
||||
class Base():
|
||||
def ret(self, b):
|
||||
return b
|
||||
|
||||
@@ -174,8 +174,6 @@ class X():
|
||||
#? int()
|
||||
X([1]).foo()
|
||||
|
||||
# set/dict comprehensions were introduced in 2.7, therefore:
|
||||
# python >= 2.7
|
||||
# -----------------
|
||||
# dict comprehensions
|
||||
# -----------------
|
||||
|
||||
@@ -388,7 +388,6 @@ k = 'a'
|
||||
#? int()
|
||||
some_dct[k]
|
||||
|
||||
# python > 3.5
|
||||
some_other_dct = dict(some_dct, c=set)
|
||||
#? int()
|
||||
some_other_dct['a']
|
||||
|
||||
@@ -242,8 +242,6 @@ def x():
|
||||
# yield from
|
||||
# -----------------
|
||||
|
||||
# python > 2.7
|
||||
|
||||
def yield_from():
|
||||
yield from iter([1])
|
||||
|
||||
|
||||
@@ -97,7 +97,6 @@ def x(): pass
|
||||
# -----------------
|
||||
# Only keyword arguments are valid
|
||||
# -----------------
|
||||
# python >= 3.5
|
||||
|
||||
def x(bam, *, bar, baz):
|
||||
pass
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
""" Pep-0484 type hinting """
|
||||
|
||||
# python > 2.7
|
||||
|
||||
|
||||
class A():
|
||||
pass
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
"""
|
||||
Test the typing library, with docstrings. This is needed since annotations
|
||||
are not supported in python 2.7 else then annotating by comment (and this is
|
||||
still TODO at 2016-01-23)
|
||||
Test the typing library, with docstrings and annotations
|
||||
"""
|
||||
import typing
|
||||
class B:
|
||||
@@ -295,8 +293,6 @@ y = type(PlainInt)
|
||||
#? type.mro
|
||||
y.mro
|
||||
|
||||
# python > 2.7
|
||||
|
||||
class TestDefaultDict(typing.DefaultDict[str, int]):
|
||||
def setdud(self):
|
||||
pass
|
||||
@@ -323,7 +319,6 @@ for key in x.keys():
|
||||
for value in x.values():
|
||||
#? int()
|
||||
value
|
||||
# python > 2.7
|
||||
|
||||
|
||||
"""
|
||||
|
||||
@@ -178,8 +178,6 @@ from datetime import datetime, timedelta
|
||||
# magic methods
|
||||
# -----------------
|
||||
|
||||
# python >= 3.5
|
||||
|
||||
class C:
|
||||
def __sub__(self, other) -> int: ...
|
||||
def __radd__(self, other) -> float: ...
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# python > 2.7
|
||||
import pytest
|
||||
from pytest import fixture
|
||||
|
||||
@@ -130,8 +129,6 @@ def test_p(monkeypatch):
|
||||
#? ['setattr']
|
||||
monkeypatch.setatt
|
||||
|
||||
# python > 2.7
|
||||
|
||||
#? ['capsysbinary']
|
||||
def test_p(capsysbin
|
||||
|
||||
|
||||
@@ -362,7 +362,6 @@ class Test(metaclass=Meta):
|
||||
# Enum
|
||||
# -----------------
|
||||
|
||||
# python > 2.7
|
||||
import enum
|
||||
|
||||
class X(enum.Enum):
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# python > 2.7
|
||||
from stub_folder import with_stub, stub_only, with_stub_folder, stub_only_folder
|
||||
|
||||
# -------------------------
|
||||
|
||||
@@ -135,7 +135,6 @@ set_t2.c
|
||||
# -----------------
|
||||
# pep 448 unpacking generalizations
|
||||
# -----------------
|
||||
# python >= 3.5
|
||||
|
||||
d = {'a': 3}
|
||||
dc = {v: 3 for v in ['a']}
|
||||
|
||||
@@ -354,7 +354,6 @@ class DefinitelyNotGlobal:
|
||||
# stubs
|
||||
# -----------------
|
||||
|
||||
# python > 2.7
|
||||
from stub_folder import with_stub
|
||||
#< ('stub:stub_folder.with_stub', 5, 4), ('stub_folder.with_stub', 5, 4), (0, 10)
|
||||
with_stub.stub_function
|
||||
|
||||
@@ -431,7 +431,7 @@ Options:
|
||||
--pdb Enable pdb debugging on fail.
|
||||
-d, --debug Enable text output debugging (please install ``colorama``).
|
||||
--thirdparty Also run thirdparty tests (in ``completion/thirdparty``).
|
||||
--env <dotted> A Python version, like 2.7, 3.8, etc.
|
||||
--env <dotted> A Python version, like 3.9, 3.8, etc.
|
||||
"""
|
||||
if __name__ == '__main__':
|
||||
import docopt
|
||||
|
||||
@@ -595,7 +595,7 @@ def test_definition_goto_follow_imports(Script):
|
||||
'foo(x: str, y: int=None) -> Union[int, str]'),
|
||||
]
|
||||
)
|
||||
def test_get_type_hint(Script, code, expected, skip_pre_python36):
|
||||
def test_get_type_hint(Script, code, expected):
|
||||
code = 'from typing import *\n' + code
|
||||
d, = Script(code).goto()
|
||||
assert d.get_type_hint() == expected
|
||||
|
||||
@@ -382,7 +382,7 @@ _dict_keys_completion_tests = [
|
||||
@pytest.mark.parametrize(
|
||||
'added_code, column, expected', _dict_keys_completion_tests
|
||||
)
|
||||
def test_dict_keys_completions(Script, added_code, column, expected, skip_pre_python36):
|
||||
def test_dict_keys_completions(Script, added_code, column, expected):
|
||||
code = dedent(r'''
|
||||
ints = {1: ''}
|
||||
ints[50] = 3.0
|
||||
@@ -405,7 +405,7 @@ def test_dict_keys_completions(Script, added_code, column, expected, skip_pre_py
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.version_info[0] == 2, reason="Ignore Python 2, because EOL")
|
||||
def test_dict_keys_in_weird_case(Script, skip_pre_python36):
|
||||
def test_dict_keys_in_weird_case(Script):
|
||||
assert Script('a[\n# foo\nx]').complete(line=2, column=0)
|
||||
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ def test_find_system_environments():
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'version',
|
||||
['2.7', '3.5', '3.6', '3.7']
|
||||
['3.6', '3.7', '3.8', '3.9']
|
||||
)
|
||||
def test_versions(version):
|
||||
try:
|
||||
|
||||
@@ -134,7 +134,7 @@ def test_load_save_project(tmpdir):
|
||||
]
|
||||
)
|
||||
@pytest.mark.skipif(sys.version_info < (3, 6), reason="Ignore Python 2, because EOL")
|
||||
def test_search(string, full_names, kwargs, skip_pre_python36):
|
||||
def test_search(string, full_names, kwargs):
|
||||
some_search_test_var = 1.0
|
||||
project = Project(test_dir)
|
||||
if kwargs.pop('complete', False) is True:
|
||||
@@ -153,7 +153,7 @@ def test_search(string, full_names, kwargs, skip_pre_python36):
|
||||
]
|
||||
)
|
||||
@pytest.mark.skipif(sys.version_info < (3, 6), reason="Ignore Python 2, because EOL")
|
||||
def test_complete_search(Script, string, completions, all_scopes, skip_pre_python36):
|
||||
def test_complete_search(Script, string, completions, all_scopes):
|
||||
project = Project(test_dir)
|
||||
defs = project.complete_search(string, all_scopes=all_scopes)
|
||||
assert [d.complete for d in defs] == completions
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import os
|
||||
import sys
|
||||
from textwrap import dedent
|
||||
|
||||
import pytest
|
||||
@@ -7,12 +6,6 @@ import pytest
|
||||
import jedi
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def skip_old_python(skip_pre_python36):
|
||||
if sys.version_info < (3, 6):
|
||||
pytest.skip()
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def dir_with_content(tmpdir):
|
||||
with open(os.path.join(tmpdir.strpath, 'modx.py'), 'w', newline='') as f:
|
||||
|
||||
@@ -65,7 +65,7 @@ class SomeClass:
|
||||
('SomeCl.twice', [], dict(all_scopes=True, complete=True, fuzzy=True)),
|
||||
]
|
||||
)
|
||||
def test_simple_search(Script, string, descriptions, kwargs, skip_pre_python36):
|
||||
def test_simple_search(Script, string, descriptions, kwargs):
|
||||
if sys.version_info < (3, 6):
|
||||
pytest.skip()
|
||||
|
||||
|
||||
@@ -51,7 +51,6 @@ def test_param_default(Script, code, expected_params):
|
||||
assert annotation.description == expected
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.version_info < (3, 5), reason="Python <3.5 doesn't support __signature__")
|
||||
@pytest.mark.parametrize(
|
||||
'code, index, param_code, kind', [
|
||||
('def f(x=1): pass\nf', 0, 'x=1', 'POSITIONAL_OR_KEYWORD'),
|
||||
|
||||
@@ -163,7 +163,7 @@ def test_docstring_params_formatting(Script):
|
||||
assert defs[0].docstring() == 'func(param1, param2, param3)'
|
||||
|
||||
|
||||
def test_import_function_docstring(Script, skip_pre_python35):
|
||||
def test_import_function_docstring(Script):
|
||||
code = "from stub_folder import with_stub; with_stub.stub_function"
|
||||
path = os.path.join(test_dir, 'completion', 'import_function_docstring.py')
|
||||
c, = Script(code, path=path).complete()
|
||||
@@ -422,7 +422,7 @@ def test_decorator(Script):
|
||||
assert d.docstring(raw=True) == 'Nice docstring'
|
||||
|
||||
|
||||
def test_method_decorator(Script, skip_pre_python35):
|
||||
def test_method_decorator(Script):
|
||||
code = dedent('''
|
||||
def decorator(func):
|
||||
@wraps(func)
|
||||
@@ -443,7 +443,7 @@ def test_method_decorator(Script, skip_pre_python35):
|
||||
assert d.docstring() == 'wrapper(f)\n\nNice docstring'
|
||||
|
||||
|
||||
def test_partial(Script, skip_pre_python36):
|
||||
def test_partial(Script):
|
||||
code = dedent('''
|
||||
def foo():
|
||||
'x y z'
|
||||
|
||||
@@ -56,7 +56,7 @@ def test_goto_on_file(Script):
|
||||
assert d2.name == 'Bar'
|
||||
|
||||
|
||||
def test_goto_import(Script, skip_pre_python35):
|
||||
def test_goto_import(Script):
|
||||
code = 'from abc import ABC; ABC'
|
||||
d, = Script(code).goto(only_stubs=True)
|
||||
assert d.is_stub()
|
||||
|
||||
@@ -104,10 +104,11 @@ def test_signature():
|
||||
assert s.docstring() == 'some_signature(*, bar=1)'
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.version_info[0:2] < (3, 5), reason="Typing was introduced in Python 3.5")
|
||||
def test_compiled_signature_annotation_string():
|
||||
import typing
|
||||
def func(x: typing.Type, y: typing.Union[typing.Type, int]): pass
|
||||
|
||||
def func(x: typing.Type, y: typing.Union[typing.Type, int]):
|
||||
pass
|
||||
func.__name__ = 'not_func'
|
||||
|
||||
s, = jedi.Interpreter('func()', [locals()]).get_signatures(1, 5)
|
||||
|
||||
@@ -175,7 +175,7 @@ def test_tree_signature(Script, environment, code, expected):
|
||||
('no_redirect(simple)', '*args, **kwargs'),
|
||||
]
|
||||
)
|
||||
def test_nested_signatures(Script, environment, combination, expected, skip_pre_python35):
|
||||
def test_nested_signatures(Script, environment, combination, expected):
|
||||
code = dedent('''
|
||||
def simple(a, b, *, c): ...
|
||||
def simple2(x): ...
|
||||
@@ -265,7 +265,7 @@ def test_pow_signature(Script):
|
||||
x(f)('''), 'f()'],
|
||||
]
|
||||
)
|
||||
def test_wraps_signature(Script, code, signature, skip_pre_python35):
|
||||
def test_wraps_signature(Script, code, signature):
|
||||
sigs = Script(code).get_signatures()
|
||||
assert {sig.to_string() for sig in sigs} == {signature}
|
||||
|
||||
@@ -315,7 +315,7 @@ def test_dataclass_signature(Script, skip_pre_python37, start, start_params):
|
||||
('kwargs = dict(b=3)', 'wrapped(b, /, **kwargs)'),
|
||||
]
|
||||
)
|
||||
def test_param_resolving_to_static(Script, stmt, expected, skip_pre_python35):
|
||||
def test_param_resolving_to_static(Script, stmt, expected):
|
||||
code = dedent('''\
|
||||
def full_redirect(func):
|
||||
def wrapped(*args, **kwargs):
|
||||
|
||||
@@ -62,7 +62,7 @@ def test_static_analysis(static_analysis_case, environment):
|
||||
static_analysis_case.run(assert_static_analysis, environment)
|
||||
|
||||
|
||||
def test_refactor(refactor_case, skip_pre_python36, environment):
|
||||
def test_refactor(refactor_case, environment):
|
||||
"""
|
||||
Run refactoring test case.
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ def test_hex_values_in_docstring():
|
||||
('lambda x, y, z: x + y * z\n', '<lambda>(x, y, z)')
|
||||
])
|
||||
def test_get_signature(code, signature):
|
||||
node = parse(code, version='3.5').children[0]
|
||||
node = parse(code, version='3.8').children[0]
|
||||
if node.type == 'simple_stmt':
|
||||
node = node.children[0]
|
||||
assert parser_utils.get_signature(node) == signature
|
||||
|
||||
9
tox.ini
9
tox.ini
@@ -1,14 +1,11 @@
|
||||
[tox]
|
||||
envlist = py27, py35, py36, py37, py38, qa
|
||||
envlist = py36, py37, py38, qa
|
||||
[testenv]
|
||||
extras = testing
|
||||
deps =
|
||||
# for testing the typing module
|
||||
py27: typing
|
||||
# numpydoc for typing scipy stack
|
||||
numpydoc
|
||||
# sphinx, a dependency of numpydoc, dropped Python 2 support in version 2.0
|
||||
sphinx < 2.0
|
||||
sphinx
|
||||
cov: coverage
|
||||
# Overwrite the parso version (only used sometimes).
|
||||
git+https://github.com/davidhalter/parso.git
|
||||
@@ -21,8 +18,6 @@ setenv =
|
||||
PYTHONWARNINGS=always
|
||||
# To test Jedi in different versions than the same Python version, set a
|
||||
# different test environment.
|
||||
env27: JEDI_TEST_ENVIRONMENT=27
|
||||
env35: JEDI_TEST_ENVIRONMENT=35
|
||||
env36: JEDI_TEST_ENVIRONMENT=36
|
||||
env37: JEDI_TEST_ENVIRONMENT=37
|
||||
env38: JEDI_TEST_ENVIRONMENT=38
|
||||
|
||||
Reference in New Issue
Block a user