From 98cc438ad86dc8d609ef7d5d2fb4779bb0e9c588 Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Fri, 7 Jul 2023 23:13:58 -0400 Subject: [PATCH] Fix DeprecationWarning --- nose/plugins/manager.py | 22 +++++++++++++++++++++- setup.py | 7 ++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/nose/plugins/manager.py b/nose/plugins/manager.py index 674edeb..e0f7aee 100644 --- a/nose/plugins/manager.py +++ b/nose/plugins/manager.py @@ -324,6 +324,27 @@ 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), @@ -331,7 +352,6 @@ class EntryPointPluginManager(PluginManager): 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): diff --git a/setup.py b/setup.py index cca7570..7e5a2b4 100644 --- a/setup.py +++ b/setup.py @@ -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(