Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_pluginmanager: use pluggy.manager.metadata #230

Merged
merged 1 commit into from
Aug 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/pluggy/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import warnings

if sys.version_info >= (3, 8):
from importlib import metadata
from importlib import metadata as importlib_metadata
else:
import importlib_metadata as metadata
import importlib_metadata


def _warn_for_function(warning, function):
Expand Down Expand Up @@ -283,7 +283,7 @@ def load_setuptools_entrypoints(self, group, name=None):
:return: return the number of loaded plugins by this call.
"""
count = 0
for dist in metadata.distributions():
for dist in importlib_metadata.distributions():
for ep in dist.entry_points:
if (
ep.group != group
Expand Down
9 changes: 2 additions & 7 deletions testing/test_pluginmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
``PluginManager`` unit and public API testing.
"""
import pytest
import sys
import types

from pluggy import (
Expand All @@ -12,11 +11,7 @@
HookimplMarker,
HookspecMarker,
)

if sys.version_info >= (3, 8):
from importlib import metadata
else:
import importlib_metadata as metadata
from pluggy.manager import importlib_metadata


hookspec = HookspecMarker("example")
Expand Down Expand Up @@ -472,7 +467,7 @@ class Distribution(object):
def my_distributions():
return (dist,)

monkeypatch.setattr(metadata, "distributions", my_distributions)
monkeypatch.setattr(importlib_metadata, "distributions", my_distributions)
num = pm.load_setuptools_entrypoints("hello")
assert num == 1
plugin = pm.get_plugin("myname")
Expand Down