From e25750ecefe1747ae631fb4264236784784a91e6 Mon Sep 17 00:00:00 2001 From: Marcio Mazza Date: Mon, 5 Sep 2022 17:01:02 -0300 Subject: [PATCH] Make code compatible with python < 3.8 --- jedi/plugins/pytest.py | 5 +++-- test/test_integration.py | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/jedi/plugins/pytest.py b/jedi/plugins/pytest.py index 25e15f28..0f6b320d 100644 --- a/jedi/plugins/pytest.py +++ b/jedi/plugins/pytest.py @@ -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() diff --git a/test/test_integration.py b/test/test_integration.py index 7f482db4..2d8e118c 100644 --- a/test/test_integration.py +++ b/test/test_integration.py @@ -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'))