mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 22:14:27 +08:00
Make code compatible with python < 3.8
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
from importlib.metadata import entry_points
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from parso.tree import search_ancestor
|
from parso.tree import search_ancestor
|
||||||
@@ -138,7 +137,9 @@ def _find_pytest_plugin_modules():
|
|||||||
|
|
||||||
See https://docs.pytest.org/en/stable/how-to/writing_plugins.html#setuptools-entry-points
|
See https://docs.pytest.org/en/stable/how-to/writing_plugins.html#setuptools-entry-points
|
||||||
"""
|
"""
|
||||||
return [ep.value.split(".") for ep in entry_points(group="pytest11")]
|
from pkg_resources import iter_entry_points
|
||||||
|
|
||||||
|
return [ep.module_name.split(".") for ep in iter_entry_points(group="pytest11")]
|
||||||
|
|
||||||
|
|
||||||
@inference_state_method_cache()
|
@inference_state_method_cache()
|
||||||
|
|||||||
@@ -52,12 +52,12 @@ def test_completion(case, monkeypatch, environment, has_django):
|
|||||||
|
|
||||||
# ... and mock setuptools entry points to include it
|
# ... and mock setuptools entry points to include it
|
||||||
# see https://docs.pytest.org/en/stable/how-to/writing_plugins.html#setuptools-entry-points
|
# see https://docs.pytest.org/en/stable/how-to/writing_plugins.html#setuptools-entry-points
|
||||||
def mock_entry_points(group):
|
def mock_iter_entry_points(group):
|
||||||
assert group == "pytest11"
|
assert group == "pytest11"
|
||||||
EntryPoint = namedtuple("EntryPoint", ["value"])
|
EntryPoint = namedtuple("EntryPoint", ["module_name"])
|
||||||
return [EntryPoint(value="pytest_plugin.plugin")]
|
return [EntryPoint("pytest_plugin.plugin")]
|
||||||
|
|
||||||
monkeypatch.setattr("jedi.plugins.pytest.entry_points", mock_entry_points)
|
monkeypatch.setattr("pkg_resources.iter_entry_points", mock_iter_entry_points)
|
||||||
|
|
||||||
repo_root = helpers.root_dir
|
repo_root = helpers.root_dir
|
||||||
monkeypatch.chdir(os.path.join(repo_root, 'jedi'))
|
monkeypatch.chdir(os.path.join(repo_root, 'jedi'))
|
||||||
|
|||||||
Reference in New Issue
Block a user