Skip to content

Commit

Permalink
Merge pull request #8 from mdmintz/fix-deprecation-warning
Browse files Browse the repository at this point in the history
Fix DeprecationWarning
  • Loading branch information
mdmintz authored Jul 8, 2023
2 parents c9825ed + 6b5f546 commit bf82868
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
<h1>pynose 🐍👃 <a href="https://pypi.python.org/pypi/pynose" target="_blank"><img src="https://img.shields.io/pypi/v/pynose.svg?color=3399EE" alt="PyPI version" /></a></h1>

### ``pynose`` fixes ``nose`` to extend [unittest](https://docs.python.org/3/library/unittest.html) and make testing easier.

(NOTE: If you can, use **[pytest](https://docs.pytest.org/)** instead. **[pynose](https://github.com/mdmintz/pynose)** was built to maintain **[nose](https://nose.readthedocs.io/en/latest/)** for developers who still use it.)
### **[pynose](https://github.com/mdmintz/pynose)** fixes **[nose](https://nose.readthedocs.io/en/latest/)** to extend [unittest](https://docs.python.org/3/library/unittest.html) and make testing easier.

--------

``pynose`` is an updated version of ``nose``, originally made by Jason Pellerin.

This version of ``nose`` is compatible with Python 3.6+ (including 3.12 & up).
This version of ``nose`` is compatible with ``Python 3.6+`` (including ``3.12+``).

Changes in ``pynose`` from legacy ``nose`` include:
* Fixes "AttributeError: module 'collections' has no attribute 'Callable'."
* Fixes "AttributeError: module 'inspect' has no attribute 'getargspec'."
* Fixes "ImportError: cannot import name '_TextTestResult' from 'unittest'."
* Fixes "RuntimeWarning: TestResult has no addDuration method."
* Fixes "DeprecationWarning: pkg_resources is deprecated as an API."
* Fixes all ``flake8`` issues from the original ``nose``.
* Replaces the ``imp`` module with the newer ``importlib`` module.
* The default logging level now hides "debug" logs for less noise.
Expand Down
2 changes: 1 addition & 1 deletion nose/__version__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# pynose nose package
__version__ = "1.4.5"
__version__ = "1.4.6"
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 bf82868

Please sign in to comment.