PyNose
PyNose is an updated version of the `nose` testing framework, designed to extend `unittest` and simplify Python testing. It aims to fix compatibility issues with newer Python versions and improve upon the original `nose` project. As of version 1.5.5, it supports Python 3.7+ (including 3.14+). It has an active release cadence, with several updates addressing compatibility and adding features recently.
Warnings
- breaking PyNose v1.5.0 dropped official support for Python 3.6. Users on Python 3.6 or older must upgrade their Python environment to at least 3.7 or use an older version of PyNose.
- gotcha Unlike legacy `nose` which captured `stdout` by default (hiding `print()` output), PyNose (from v1.4.8 onwards) makes `print()` output visible by default (equivalent to `nose -s`). To suppress `print()` output, use the `--capture-output` command-line option.
- gotcha PyNose automatically skips tests that utilize `pytest` fixtures. This can lead to tests not being run as expected if a project mixes `nose`-style tests with `pytest` fixture-based tests.
- deprecated The use of multiple `-w` arguments to specify working directories for test discovery is deprecated and will be removed in a future release.
- gotcha PyNose is a modern replacement for the abandoned `nose` project. While largely a drop-in, projects migrating directly from original `nose` might encounter subtle differences in behavior or unsupported `nose` idioms (e.g., specific `sys.path` manipulations, certain `nose`-style doctests, or `yield`-based methods) that were part of the legacy implementation.
Install
-
pip install pynose
Imports
- nose.main
import nose # Then call nose.main() or nose.run()
Quickstart
# test_example.py
import unittest
class MyTestCase(unittest.TestCase):
def test_addition(self):
self.assertEqual(1 + 1, 2)
def test_subtraction(self):
self.assertEqual(2 - 1, 1)
def test_simple_function():
assert True
# To run these tests from the command line, save this file
# and then execute 'pynose' or 'nosetests' in your terminal.
# Example: pynose test_example.py