mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +08:00
Refactoring is not allowed for environments and the current version lower than 3.6
This commit is contained in:
@@ -54,11 +54,7 @@ sys.setrecursionlimit(3000)
|
|||||||
def no_py2_support(func):
|
def no_py2_support(func):
|
||||||
# TODO remove when removing Python 2/3.5
|
# TODO remove when removing Python 2/3.5
|
||||||
def wrapper(self, *args, **kwargs):
|
def wrapper(self, *args, **kwargs):
|
||||||
if self._inference_state.grammar.version_info.major == 2:
|
if self._inference_state.grammar.version_info < (3, 6) or sys.version_info < (3, 6):
|
||||||
raise NotImplementedError(
|
|
||||||
"Python 2 is deprecated and won't support this feature anymore"
|
|
||||||
)
|
|
||||||
if self._inference_state.grammar.version_info[:2] == (3, 5):
|
|
||||||
raise NotImplementedError(
|
raise NotImplementedError(
|
||||||
"No support for refactorings on Python 3.5"
|
"No support for refactorings on Python 3.5"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
from textwrap import dedent
|
from textwrap import dedent
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
@@ -6,6 +7,12 @@ 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') as f:
|
with open(os.path.join(tmpdir.strpath, 'modx.py'), 'w') as f:
|
||||||
@@ -13,7 +20,7 @@ def dir_with_content(tmpdir):
|
|||||||
return tmpdir.strpath
|
return tmpdir.strpath
|
||||||
|
|
||||||
|
|
||||||
def test_rename_mod(Script, dir_with_content, skip_pre_python36):
|
def test_rename_mod(Script, dir_with_content):
|
||||||
script = Script(
|
script = Script(
|
||||||
'import modx; modx\n',
|
'import modx; modx\n',
|
||||||
path=os.path.join(dir_with_content, 'some_script.py'),
|
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)
|
''').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')
|
refactoring = Script('foo', path=None).rename(new_name='bar')
|
||||||
with pytest.raises(jedi.RefactoringError, match='on a Script with path=None'):
|
with pytest.raises(jedi.RefactoringError, match='on a Script with path=None'):
|
||||||
refactoring.apply()
|
refactoring.apply()
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
@@ -62,6 +63,9 @@ def test_refactor(refactor_case, skip_pre_python36, environment):
|
|||||||
|
|
||||||
:type refactor_case: :class:`.refactor.RefactoringCase`
|
:type refactor_case: :class:`.refactor.RefactoringCase`
|
||||||
"""
|
"""
|
||||||
|
if sys.version_info < (3, 6):
|
||||||
|
pytest.skip()
|
||||||
|
|
||||||
if refactor_case.type == 'error':
|
if refactor_case.type == 'error':
|
||||||
with pytest.raises(RefactoringError) as e:
|
with pytest.raises(RefactoringError) as e:
|
||||||
refactor_case.refactor(environment)
|
refactor_case.refactor(environment)
|
||||||
|
|||||||
Reference in New Issue
Block a user