Remove a lot of test references to Python 2/3.5

This commit is contained in:
Dave Halter
2020-07-02 00:17:21 +02:00
parent 0e5869b52f
commit 50b85153ce
32 changed files with 24 additions and 87 deletions

View File

@@ -1,7 +1,6 @@
import tempfile import tempfile
import shutil import shutil
import os import os
import sys
from functools import partial from functools import partial
import pytest import pytest
@@ -18,9 +17,6 @@ collect_ignore = [
'build/', 'build/',
'test/examples', '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 # The following hooks (pytest_configure, pytest_unconfigure) are used
@@ -45,7 +41,7 @@ def pytest_addoption(parser):
help="Warnings are treated as errors.") help="Warnings are treated as errors.")
parser.addoption("--env", action='store', 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', parser.addoption("--interpreter-env", "-I", action='store_true',
help="Don't use subprocesses to guarantee having safe " help="Don't use subprocesses to guarantee having safe "
"code execution. Useful for debugging.") "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 # This if is just needed to avoid that tests ever skip way more than
# they should for all Python versions. # they should for all Python versions.
pytest.skip() 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()

View File

@@ -272,9 +272,6 @@ dic = {str(key): ''}
#? str() #? str()
dic[''] 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}: for x in {1: 3.0, '': 1j}:
#? int() str() #? int() str()
@@ -473,7 +470,6 @@ def test_func():
#? int() #? int()
tuple({1})[0] tuple({1})[0]
# python > 2.7
# ----------------- # -----------------
# PEP 3132 Extended Iterable Unpacking (star unpacking) # PEP 3132 Extended Iterable Unpacking (star unpacking)
# ----------------- # -----------------

View File

@@ -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. raise errors or return extremely strange results.
""" """
# python >= 3.5
async def x(): async def x():
return 1 return 1

View File

@@ -344,8 +344,6 @@ def foo(my_t=some_defa
#? ['some_default'] #? ['some_default']
def foo(my_t=some_defa, my_t2=some_defa def foo(my_t=some_defa, my_t2=some_defa
# python > 2.7
#? ['my_type'] #? ['my_type']
def foo(my_t: lala=some_defa, my_t2: my_typ def foo(my_t: lala=some_defa, my_t2: my_typ
#? ['my_type'] #? ['my_type']

View File

@@ -382,7 +382,6 @@ getattr(getattr, 1)
getattr(str, []) getattr(str, [])
# python >= 3.5
class Base(): class Base():
def ret(self, b): def ret(self, b):
return b return b

View File

@@ -174,8 +174,6 @@ class X():
#? int() #? int()
X([1]).foo() X([1]).foo()
# set/dict comprehensions were introduced in 2.7, therefore:
# python >= 2.7
# ----------------- # -----------------
# dict comprehensions # dict comprehensions
# ----------------- # -----------------

View File

@@ -388,7 +388,6 @@ k = 'a'
#? int() #? int()
some_dct[k] some_dct[k]
# python > 3.5
some_other_dct = dict(some_dct, c=set) some_other_dct = dict(some_dct, c=set)
#? int() #? int()
some_other_dct['a'] some_other_dct['a']

View File

@@ -242,8 +242,6 @@ def x():
# yield from # yield from
# ----------------- # -----------------
# python > 2.7
def yield_from(): def yield_from():
yield from iter([1]) yield from iter([1])

View File

@@ -97,7 +97,6 @@ def x(): pass
# ----------------- # -----------------
# Only keyword arguments are valid # Only keyword arguments are valid
# ----------------- # -----------------
# python >= 3.5
def x(bam, *, bar, baz): def x(bam, *, bar, baz):
pass pass

View File

@@ -1,7 +1,5 @@
""" Pep-0484 type hinting """ """ Pep-0484 type hinting """
# python > 2.7
class A(): class A():
pass pass

View File

@@ -1,7 +1,5 @@
""" """
Test the typing library, with docstrings. This is needed since annotations Test the typing library, with docstrings and annotations
are not supported in python 2.7 else then annotating by comment (and this is
still TODO at 2016-01-23)
""" """
import typing import typing
class B: class B:
@@ -295,8 +293,6 @@ y = type(PlainInt)
#? type.mro #? type.mro
y.mro y.mro
# python > 2.7
class TestDefaultDict(typing.DefaultDict[str, int]): class TestDefaultDict(typing.DefaultDict[str, int]):
def setdud(self): def setdud(self):
pass pass
@@ -323,7 +319,6 @@ for key in x.keys():
for value in x.values(): for value in x.values():
#? int() #? int()
value value
# python > 2.7
""" """

View File

@@ -178,8 +178,6 @@ from datetime import datetime, timedelta
# magic methods # magic methods
# ----------------- # -----------------
# python >= 3.5
class C: class C:
def __sub__(self, other) -> int: ... def __sub__(self, other) -> int: ...
def __radd__(self, other) -> float: ... def __radd__(self, other) -> float: ...

View File

@@ -1,4 +1,3 @@
# python > 2.7
import pytest import pytest
from pytest import fixture from pytest import fixture
@@ -130,8 +129,6 @@ def test_p(monkeypatch):
#? ['setattr'] #? ['setattr']
monkeypatch.setatt monkeypatch.setatt
# python > 2.7
#? ['capsysbinary'] #? ['capsysbinary']
def test_p(capsysbin def test_p(capsysbin

View File

@@ -362,7 +362,6 @@ class Test(metaclass=Meta):
# Enum # Enum
# ----------------- # -----------------
# python > 2.7
import enum import enum
class X(enum.Enum): class X(enum.Enum):

View File

@@ -1,4 +1,3 @@
# python > 2.7
from stub_folder import with_stub, stub_only, with_stub_folder, stub_only_folder from stub_folder import with_stub, stub_only, with_stub_folder, stub_only_folder
# ------------------------- # -------------------------

View File

@@ -135,7 +135,6 @@ set_t2.c
# ----------------- # -----------------
# pep 448 unpacking generalizations # pep 448 unpacking generalizations
# ----------------- # -----------------
# python >= 3.5
d = {'a': 3} d = {'a': 3}
dc = {v: 3 for v in ['a']} dc = {v: 3 for v in ['a']}

View File

@@ -354,7 +354,6 @@ class DefinitelyNotGlobal:
# stubs # stubs
# ----------------- # -----------------
# python > 2.7
from stub_folder import with_stub from stub_folder import with_stub
#< ('stub:stub_folder.with_stub', 5, 4), ('stub_folder.with_stub', 5, 4), (0, 10) #< ('stub:stub_folder.with_stub', 5, 4), ('stub_folder.with_stub', 5, 4), (0, 10)
with_stub.stub_function with_stub.stub_function

View File

@@ -431,7 +431,7 @@ Options:
--pdb Enable pdb debugging on fail. --pdb Enable pdb debugging on fail.
-d, --debug Enable text output debugging (please install ``colorama``). -d, --debug Enable text output debugging (please install ``colorama``).
--thirdparty Also run thirdparty tests (in ``completion/thirdparty``). --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__': if __name__ == '__main__':
import docopt import docopt

View File

@@ -595,7 +595,7 @@ def test_definition_goto_follow_imports(Script):
'foo(x: str, y: int=None) -> Union[int, str]'), '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 code = 'from typing import *\n' + code
d, = Script(code).goto() d, = Script(code).goto()
assert d.get_type_hint() == expected assert d.get_type_hint() == expected

View File

@@ -382,7 +382,7 @@ _dict_keys_completion_tests = [
@pytest.mark.parametrize( @pytest.mark.parametrize(
'added_code, column, expected', _dict_keys_completion_tests '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''' code = dedent(r'''
ints = {1: ''} ints = {1: ''}
ints[50] = 3.0 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") @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) assert Script('a[\n# foo\nx]').complete(line=2, column=0)

View File

@@ -27,7 +27,7 @@ def test_find_system_environments():
@pytest.mark.parametrize( @pytest.mark.parametrize(
'version', 'version',
['2.7', '3.5', '3.6', '3.7'] ['3.6', '3.7', '3.8', '3.9']
) )
def test_versions(version): def test_versions(version):
try: try:

View File

@@ -134,7 +134,7 @@ def test_load_save_project(tmpdir):
] ]
) )
@pytest.mark.skipif(sys.version_info < (3, 6), reason="Ignore Python 2, because EOL") @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 some_search_test_var = 1.0
project = Project(test_dir) project = Project(test_dir)
if kwargs.pop('complete', False) is True: 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") @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) project = Project(test_dir)
defs = project.complete_search(string, all_scopes=all_scopes) defs = project.complete_search(string, all_scopes=all_scopes)
assert [d.complete for d in defs] == completions assert [d.complete for d in defs] == completions

View File

@@ -1,5 +1,4 @@
import os import os
import sys
from textwrap import dedent from textwrap import dedent
import pytest import pytest
@@ -7,12 +6,6 @@ import pytest
import jedi import jedi
@pytest.fixture(autouse=True)
def skip_old_python(skip_pre_python36):
if sys.version_info < (3, 6):
pytest.skip()
@pytest.fixture() @pytest.fixture()
def dir_with_content(tmpdir): def dir_with_content(tmpdir):
with open(os.path.join(tmpdir.strpath, 'modx.py'), 'w', newline='') as f: with open(os.path.join(tmpdir.strpath, 'modx.py'), 'w', newline='') as f:

View File

@@ -65,7 +65,7 @@ class SomeClass:
('SomeCl.twice', [], dict(all_scopes=True, complete=True, fuzzy=True)), ('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): if sys.version_info < (3, 6):
pytest.skip() pytest.skip()

View File

@@ -51,7 +51,6 @@ def test_param_default(Script, code, expected_params):
assert annotation.description == expected assert annotation.description == expected
@pytest.mark.skipif(sys.version_info < (3, 5), reason="Python <3.5 doesn't support __signature__")
@pytest.mark.parametrize( @pytest.mark.parametrize(
'code, index, param_code, kind', [ 'code, index, param_code, kind', [
('def f(x=1): pass\nf', 0, 'x=1', 'POSITIONAL_OR_KEYWORD'), ('def f(x=1): pass\nf', 0, 'x=1', 'POSITIONAL_OR_KEYWORD'),

View File

@@ -163,7 +163,7 @@ def test_docstring_params_formatting(Script):
assert defs[0].docstring() == 'func(param1, param2, param3)' 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" code = "from stub_folder import with_stub; with_stub.stub_function"
path = os.path.join(test_dir, 'completion', 'import_function_docstring.py') path = os.path.join(test_dir, 'completion', 'import_function_docstring.py')
c, = Script(code, path=path).complete() c, = Script(code, path=path).complete()
@@ -422,7 +422,7 @@ def test_decorator(Script):
assert d.docstring(raw=True) == 'Nice docstring' assert d.docstring(raw=True) == 'Nice docstring'
def test_method_decorator(Script, skip_pre_python35): def test_method_decorator(Script):
code = dedent(''' code = dedent('''
def decorator(func): def decorator(func):
@wraps(func) @wraps(func)
@@ -443,7 +443,7 @@ def test_method_decorator(Script, skip_pre_python35):
assert d.docstring() == 'wrapper(f)\n\nNice docstring' assert d.docstring() == 'wrapper(f)\n\nNice docstring'
def test_partial(Script, skip_pre_python36): def test_partial(Script):
code = dedent(''' code = dedent('''
def foo(): def foo():
'x y z' 'x y z'

View File

@@ -56,7 +56,7 @@ def test_goto_on_file(Script):
assert d2.name == 'Bar' assert d2.name == 'Bar'
def test_goto_import(Script, skip_pre_python35): def test_goto_import(Script):
code = 'from abc import ABC; ABC' code = 'from abc import ABC; ABC'
d, = Script(code).goto(only_stubs=True) d, = Script(code).goto(only_stubs=True)
assert d.is_stub() assert d.is_stub()

View File

@@ -104,10 +104,11 @@ def test_signature():
assert s.docstring() == 'some_signature(*, bar=1)' 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(): def test_compiled_signature_annotation_string():
import typing 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' func.__name__ = 'not_func'
s, = jedi.Interpreter('func()', [locals()]).get_signatures(1, 5) s, = jedi.Interpreter('func()', [locals()]).get_signatures(1, 5)

View File

@@ -175,7 +175,7 @@ def test_tree_signature(Script, environment, code, expected):
('no_redirect(simple)', '*args, **kwargs'), ('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(''' code = dedent('''
def simple(a, b, *, c): ... def simple(a, b, *, c): ...
def simple2(x): ... def simple2(x): ...
@@ -265,7 +265,7 @@ def test_pow_signature(Script):
x(f)('''), 'f()'], 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() sigs = Script(code).get_signatures()
assert {sig.to_string() for sig in sigs} == {signature} 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)'), ('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('''\ code = dedent('''\
def full_redirect(func): def full_redirect(func):
def wrapped(*args, **kwargs): def wrapped(*args, **kwargs):

View File

@@ -62,7 +62,7 @@ def test_static_analysis(static_analysis_case, environment):
static_analysis_case.run(assert_static_analysis, 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. Run refactoring test case.

View File

@@ -68,7 +68,7 @@ def test_hex_values_in_docstring():
('lambda x, y, z: x + y * z\n', '<lambda>(x, y, z)') ('lambda x, y, z: x + y * z\n', '<lambda>(x, y, z)')
]) ])
def test_get_signature(code, signature): 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': if node.type == 'simple_stmt':
node = node.children[0] node = node.children[0]
assert parser_utils.get_signature(node) == signature assert parser_utils.get_signature(node) == signature

View File

@@ -1,14 +1,11 @@
[tox] [tox]
envlist = py27, py35, py36, py37, py38, qa envlist = py36, py37, py38, qa
[testenv] [testenv]
extras = testing extras = testing
deps = deps =
# for testing the typing module
py27: typing
# numpydoc for typing scipy stack # numpydoc for typing scipy stack
numpydoc numpydoc
# sphinx, a dependency of numpydoc, dropped Python 2 support in version 2.0 sphinx
sphinx < 2.0
cov: coverage cov: coverage
# Overwrite the parso version (only used sometimes). # Overwrite the parso version (only used sometimes).
git+https://github.com/davidhalter/parso.git git+https://github.com/davidhalter/parso.git
@@ -21,8 +18,6 @@ setenv =
PYTHONWARNINGS=always PYTHONWARNINGS=always
# To test Jedi in different versions than the same Python version, set a # To test Jedi in different versions than the same Python version, set a
# different test environment. # different test environment.
env27: JEDI_TEST_ENVIRONMENT=27
env35: JEDI_TEST_ENVIRONMENT=35
env36: JEDI_TEST_ENVIRONMENT=36 env36: JEDI_TEST_ENVIRONMENT=36
env37: JEDI_TEST_ENVIRONMENT=37 env37: JEDI_TEST_ENVIRONMENT=37
env38: JEDI_TEST_ENVIRONMENT=38 env38: JEDI_TEST_ENVIRONMENT=38