Skip to content

Commit

Permalink
Fix DeprecationWarning
Browse files Browse the repository at this point in the history
  • Loading branch information
mdmintz committed Jul 8, 2023
1 parent c9825ed commit 98cc438
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
22 changes: 21 additions & 1 deletion nose/plugins/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,14 +324,34 @@ def __getattr__(self, val):
return getattr(self.plugin, val)


def iter_entry_points(group_name):
try:
from importlib.metadata import entry_points
except (ImportError, Exception):
try:
from pkg_resources import iter_entry_points
except (ImportError, OSError):
return []
else:
return iter_entry_points(group_name)
groups = entry_points()
if hasattr(groups, 'select'):
# New interface in Python 3.10 and newer versions of the
# importlib_metadata backport.
return groups.select(group=group_name)
else:
# Older interface, deprecated in Python 3.10 and recent
# importlib_metadata, but we need it in Python 3.8 and 3.9.
return groups.get(group_name, [])


class EntryPointPluginManager(PluginManager):
"""Plugin manager that loads plugins from `nose.plugins` entry points."""
entry_points = (('nose.plugins.0.10', None),
('nose.plugins', ZeroNinePlugin))

def loadPlugins(self):
"""Load plugins by iterating the `nose.plugins` entry point."""
from pkg_resources import iter_entry_points
loaded = {}
for entry_point, adapt in self.entry_points:
for ep in iter_entry_points(entry_point):
Expand Down
7 changes: 6 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@

addl_args = dict(
packages=["nose", "nose.plugins", "nose.sphinx", "nose.tools"],
scripts=["bin/nosetests", "bin/pynose"],
entry_points={
"console_scripts": [
"nosetests = nose.core:run_exit",
"pynose = nose.core:run_exit",
]
},
)

setup(
Expand Down

0 comments on commit 98cc438

Please sign in to comment.