From 1f773d8e652b8003276c6a2cdb306b120b62fbac Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Thu, 27 Feb 2020 23:24:23 +0100 Subject: [PATCH] Refactoring is not allowed for environments and the current version lower than 3.6 --- jedi/api/__init__.py | 6 +----- test/test_api/test_refactoring.py | 11 +++++++++-- test/test_integration.py | 4 ++++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/jedi/api/__init__.py b/jedi/api/__init__.py index 85ceadea..5180df41 100644 --- a/jedi/api/__init__.py +++ b/jedi/api/__init__.py @@ -54,11 +54,7 @@ sys.setrecursionlimit(3000) def no_py2_support(func): # TODO remove when removing Python 2/3.5 def wrapper(self, *args, **kwargs): - if self._inference_state.grammar.version_info.major == 2: - raise NotImplementedError( - "Python 2 is deprecated and won't support this feature anymore" - ) - if self._inference_state.grammar.version_info[:2] == (3, 5): + if self._inference_state.grammar.version_info < (3, 6) or sys.version_info < (3, 6): raise NotImplementedError( "No support for refactorings on Python 3.5" ) diff --git a/test/test_api/test_refactoring.py b/test/test_api/test_refactoring.py index dbe430d7..03a8db40 100644 --- a/test/test_api/test_refactoring.py +++ b/test/test_api/test_refactoring.py @@ -1,4 +1,5 @@ import os +import sys from textwrap import dedent import pytest @@ -6,6 +7,12 @@ 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') as f: @@ -13,7 +20,7 @@ def dir_with_content(tmpdir): return tmpdir.strpath -def test_rename_mod(Script, dir_with_content, skip_pre_python36): +def test_rename_mod(Script, dir_with_content): script = Script( 'import modx; modx\n', path=os.path.join(dir_with_content, 'some_script.py'), @@ -50,7 +57,7 @@ def test_rename_mod(Script, dir_with_content, skip_pre_python36): ''').format(dir=dir_with_content) -def test_rename_none_path(Script, skip_pre_python36): +def test_rename_none_path(Script): refactoring = Script('foo', path=None).rename(new_name='bar') with pytest.raises(jedi.RefactoringError, match='on a Script with path=None'): refactoring.apply() diff --git a/test/test_integration.py b/test/test_integration.py index d4b1062c..883622d3 100644 --- a/test/test_integration.py +++ b/test/test_integration.py @@ -1,4 +1,5 @@ import os +import sys import pytest @@ -62,6 +63,9 @@ def test_refactor(refactor_case, skip_pre_python36, environment): :type refactor_case: :class:`.refactor.RefactoringCase` """ + if sys.version_info < (3, 6): + pytest.skip() + if refactor_case.type == 'error': with pytest.raises(RefactoringError) as e: refactor_case.refactor(environment)