From 50b85153ce33c01cba9d4b289f2a71868d5da424 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Thu, 2 Jul 2020 00:17:21 +0200 Subject: [PATCH] Remove a lot of test references to Python 2/3.5 --- conftest.py | 22 +------------------ test/completion/arrays.py | 4 ---- test/completion/async_.py | 2 -- test/completion/basic.py | 2 -- test/completion/classes.py | 1 - test/completion/comprehensions.py | 2 -- test/completion/dynamic_arrays.py | 1 - test/completion/generators.py | 2 -- test/completion/named_param.py | 1 - test/completion/pep0484_basic.py | 2 -- test/completion/pep0484_typing.py | 7 +----- test/completion/precedence.py | 2 -- test/completion/pytest.py | 3 --- test/completion/stdlib.py | 1 - test/completion/stubs.py | 1 - test/completion/types.py | 1 - test/completion/usages.py | 1 - test/run.py | 2 +- test/test_api/test_classes.py | 2 +- test/test_api/test_completion.py | 4 ++-- test/test_api/test_environment.py | 2 +- test/test_api/test_project.py | 4 ++-- test/test_api/test_refactoring.py | 7 ------ test/test_api/test_search.py | 2 +- test/test_api/test_signatures.py | 1 - test/test_inference/test_docstring.py | 6 ++--- .../test_gradual/test_conversion.py | 2 +- test/test_inference/test_mixed.py | 5 +++-- test/test_inference/test_signature.py | 6 ++--- test/test_integration.py | 2 +- .../test_parser_utils.py | 2 +- tox.ini | 9 ++------ 32 files changed, 24 insertions(+), 87 deletions(-) diff --git a/conftest.py b/conftest.py index 08c5e81a..e42576ee 100644 --- a/conftest.py +++ b/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() diff --git a/test/completion/arrays.py b/test/completion/arrays.py index 3d2e108f..545082d6 100644 --- a/test/completion/arrays.py +++ b/test/completion/arrays.py @@ -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) # ----------------- diff --git a/test/completion/async_.py b/test/completion/async_.py index e77a290e..2b6ad699 100644 --- a/test/completion/async_.py +++ b/test/completion/async_.py @@ -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 diff --git a/test/completion/basic.py b/test/completion/basic.py index b0e71bad..d0494ec3 100644 --- a/test/completion/basic.py +++ b/test/completion/basic.py @@ -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'] diff --git a/test/completion/classes.py b/test/completion/classes.py index 9d5c7c3d..9f1468b9 100644 --- a/test/completion/classes.py +++ b/test/completion/classes.py @@ -382,7 +382,6 @@ getattr(getattr, 1) getattr(str, []) -# python >= 3.5 class Base(): def ret(self, b): return b diff --git a/test/completion/comprehensions.py b/test/completion/comprehensions.py index 55f2b0c3..e0d4054c 100644 --- a/test/completion/comprehensions.py +++ b/test/completion/comprehensions.py @@ -174,8 +174,6 @@ class X(): #? int() X([1]).foo() -# set/dict comprehensions were introduced in 2.7, therefore: -# python >= 2.7 # ----------------- # dict comprehensions # ----------------- diff --git a/test/completion/dynamic_arrays.py b/test/completion/dynamic_arrays.py index 36715a98..61cc3839 100644 --- a/test/completion/dynamic_arrays.py +++ b/test/completion/dynamic_arrays.py @@ -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'] diff --git a/test/completion/generators.py b/test/completion/generators.py index 566f0036..5b3ff3e3 100644 --- a/test/completion/generators.py +++ b/test/completion/generators.py @@ -242,8 +242,6 @@ def x(): # yield from # ----------------- -# python > 2.7 - def yield_from(): yield from iter([1]) diff --git a/test/completion/named_param.py b/test/completion/named_param.py index 811c97e8..de8073e9 100644 --- a/test/completion/named_param.py +++ b/test/completion/named_param.py @@ -97,7 +97,6 @@ def x(): pass # ----------------- # Only keyword arguments are valid # ----------------- -# python >= 3.5 def x(bam, *, bar, baz): pass diff --git a/test/completion/pep0484_basic.py b/test/completion/pep0484_basic.py index a20475ca..54ec8770 100644 --- a/test/completion/pep0484_basic.py +++ b/test/completion/pep0484_basic.py @@ -1,7 +1,5 @@ """ Pep-0484 type hinting """ -# python > 2.7 - class A(): pass diff --git a/test/completion/pep0484_typing.py b/test/completion/pep0484_typing.py index 1fab1ad5..dae4b9b3 100644 --- a/test/completion/pep0484_typing.py +++ b/test/completion/pep0484_typing.py @@ -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 """ diff --git a/test/completion/precedence.py b/test/completion/precedence.py index 25d4663f..5d8da12d 100644 --- a/test/completion/precedence.py +++ b/test/completion/precedence.py @@ -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: ... diff --git a/test/completion/pytest.py b/test/completion/pytest.py index c4030918..f49fd921 100644 --- a/test/completion/pytest.py +++ b/test/completion/pytest.py @@ -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 diff --git a/test/completion/stdlib.py b/test/completion/stdlib.py index 7dcc6c37..fc8f0f14 100644 --- a/test/completion/stdlib.py +++ b/test/completion/stdlib.py @@ -362,7 +362,6 @@ class Test(metaclass=Meta): # Enum # ----------------- -# python > 2.7 import enum class X(enum.Enum): diff --git a/test/completion/stubs.py b/test/completion/stubs.py index 4e24eef1..a99549b0 100644 --- a/test/completion/stubs.py +++ b/test/completion/stubs.py @@ -1,4 +1,3 @@ -# python > 2.7 from stub_folder import with_stub, stub_only, with_stub_folder, stub_only_folder # ------------------------- diff --git a/test/completion/types.py b/test/completion/types.py index 753af6c3..e67be4e1 100644 --- a/test/completion/types.py +++ b/test/completion/types.py @@ -135,7 +135,6 @@ set_t2.c # ----------------- # pep 448 unpacking generalizations # ----------------- -# python >= 3.5 d = {'a': 3} dc = {v: 3 for v in ['a']} diff --git a/test/completion/usages.py b/test/completion/usages.py index 312765b2..9ed9ae61 100644 --- a/test/completion/usages.py +++ b/test/completion/usages.py @@ -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 diff --git a/test/run.py b/test/run.py index 731e9b4a..a169b21b 100755 --- a/test/run.py +++ b/test/run.py @@ -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 A Python version, like 2.7, 3.8, etc. + --env A Python version, like 3.9, 3.8, etc. """ if __name__ == '__main__': import docopt diff --git a/test/test_api/test_classes.py b/test/test_api/test_classes.py index c756b5e6..21f9875a 100644 --- a/test/test_api/test_classes.py +++ b/test/test_api/test_classes.py @@ -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 diff --git a/test/test_api/test_completion.py b/test/test_api/test_completion.py index 300781f6..eda88fe2 100644 --- a/test/test_api/test_completion.py +++ b/test/test_api/test_completion.py @@ -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) diff --git a/test/test_api/test_environment.py b/test/test_api/test_environment.py index ef3815a8..e4b24c56 100644 --- a/test/test_api/test_environment.py +++ b/test/test_api/test_environment.py @@ -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: diff --git a/test/test_api/test_project.py b/test/test_api/test_project.py index 48e83378..5daa43a3 100644 --- a/test/test_api/test_project.py +++ b/test/test_api/test_project.py @@ -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 diff --git a/test/test_api/test_refactoring.py b/test/test_api/test_refactoring.py index bf03d879..24a9d27a 100644 --- a/test/test_api/test_refactoring.py +++ b/test/test_api/test_refactoring.py @@ -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: diff --git a/test/test_api/test_search.py b/test/test_api/test_search.py index 0f38b560..a2b333ca 100644 --- a/test/test_api/test_search.py +++ b/test/test_api/test_search.py @@ -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() diff --git a/test/test_api/test_signatures.py b/test/test_api/test_signatures.py index 40cbf03d..0fe6d408 100644 --- a/test/test_api/test_signatures.py +++ b/test/test_api/test_signatures.py @@ -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'), diff --git a/test/test_inference/test_docstring.py b/test/test_inference/test_docstring.py index 0154db84..43a26bbe 100644 --- a/test/test_inference/test_docstring.py +++ b/test/test_inference/test_docstring.py @@ -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' diff --git a/test/test_inference/test_gradual/test_conversion.py b/test/test_inference/test_gradual/test_conversion.py index fd05d265..fd201aee 100644 --- a/test/test_inference/test_gradual/test_conversion.py +++ b/test/test_inference/test_gradual/test_conversion.py @@ -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() diff --git a/test/test_inference/test_mixed.py b/test/test_inference/test_mixed.py index fce1929f..f04d0340 100644 --- a/test/test_inference/test_mixed.py +++ b/test/test_inference/test_mixed.py @@ -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) diff --git a/test/test_inference/test_signature.py b/test/test_inference/test_signature.py index f771beec..eb723725 100644 --- a/test/test_inference/test_signature.py +++ b/test/test_inference/test_signature.py @@ -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): diff --git a/test/test_integration.py b/test/test_integration.py index b55aca77..c66782a8 100644 --- a/test/test_integration.py +++ b/test/test_integration.py @@ -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. diff --git a/test/test_parso_integration/test_parser_utils.py b/test/test_parso_integration/test_parser_utils.py index b5a3167a..e513b875 100644 --- a/test/test_parso_integration/test_parser_utils.py +++ b/test/test_parso_integration/test_parser_utils.py @@ -68,7 +68,7 @@ def test_hex_values_in_docstring(): ('lambda x, y, z: x + y * z\n', '(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 diff --git a/tox.ini b/tox.ini index a24e5c99..a8304353 100644 --- a/tox.ini +++ b/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