Make code compatible with python < 3.8

This commit is contained in:
Marcio Mazza
2022-09-05 17:01:02 -03:00
parent 1a306fddbf
commit e25750ecef
2 changed files with 7 additions and 6 deletions

View File

@@ -1,4 +1,3 @@
from importlib.metadata import entry_points
from pathlib import Path
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
"""
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()

View File

@@ -52,12 +52,12 @@ def test_completion(case, monkeypatch, environment, has_django):
# ... and mock setuptools entry points to include it
# 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"
EntryPoint = namedtuple("EntryPoint", ["value"])
return [EntryPoint(value="pytest_plugin.plugin")]
EntryPoint = namedtuple("EntryPoint", ["module_name"])
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
monkeypatch.chdir(os.path.join(repo_root, 'jedi'))