Package: nose2
Welcome to nose2nose2’s extendsunittestto make testing nicer.nose2 vs nosenose2originated as the successor tonose.nose2is a distinct project and does not support all of the behaviors ofnose.
Seedifferencesfor a thorough rundown.nose2 vs pytestpytestis an excellent test framework and we encourage users to consider
it for new projects.It has a bigger team of maintainers and a larger community of users.QuickstartBecausenose2is based on unittest, you can start from the Python Standard
Library’sdocumentation for unittestand then use nose2 to add value on top of that.nose2looks for tests in Python files whose names start withtestand
runs every test function it discovers.Here’s an example of a simple test, written in typical unittest style:# in test_simple.pyimportunittestclassTestStrings(unittest.TestCase):deftest_upper(self):self.assertEqual("spam".upper(),"SPAM")You can then run this test like so:$ nose2 -v
test_upper (test_simple.TestStrings) ... ok

----------------------------------------------------------------------
Ran 1 test in 0.000s

OKHowever,nose2supports more testing configuration and provides more tools
thanunitteston its own.For example, this test exercises just a few ofnose2’s features:# in test_fancy.pyfromnose2.toolsimportparams@params("Sir Bedevere","Miss Islington","Duck")deftest_is_knight(value):assertvalue.startswith('Sir')and then run this like so:$ nose2 -v --pretty-assert
test_fancy.test_is_knight:1
'Sir Bedevere' ... ok
test_fancy.test_is_knight:2
'Miss Islington' ... FAIL
test_fancy.test_is_knight:3
'Duck' ... FAIL

======================================================================
FAIL: test_fancy.test_is_knight:2
'Miss Islington'
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/mnt/ebs/home/sirosen/tmp/test_fancy.py", line 6, in test_is_knight
    assert value.startswith('Sir')
AssertionError

>>> assert value.startswith('Sir')

values:
    value = 'Miss Islington'
    value.startswith = <built-in method startswith of str object at 0x7f3c3172f430>
======================================================================
FAIL: test_fancy.test_is_knight:3
'Duck'
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/mnt/ebs/home/sirosen/tmp/test_fancy.py", line 6, in test_is_knight
    assert value.startswith('Sir')
AssertionError

>>> assert value.startswith('Sir')

values:
    value = 'Duck'
    value.startswith = <built-in method startswith of str object at 0x7f3c3172d490>
----------------------------------------------------------------------
Ran 3 tests in 0.001s

FAILED (failures=2)Full DocsFull documentation fornose2is available atdocs.nose2.ioVersions and SupportChangelog and Version Schemenose2 versions are numbered0.MAJOR.MINOR. Minor releases contain bugfixes or
smaller features. Major features or backwards incompatible changes are done in
major releases.For a full description of all past versions and changes, see thechangelog.Python Versionsnose2 requires Python 3.It supports all versions currently supported by the CPython team, and also aims
to support PyPy and cpython betas.Python 2Python 2 is no longer supported. The0.12.x line of releasescontains the last versions which supported Python 2.Users of Python 2 should understand that Python 2 is EOL and the Python 2
support line fornose2is similarly considered EOL.NoteFixes to 0.12.x may still be accepted on an as-needed basis for a short
while as the python3-only line of releases gets started.ContributingIf you want to make contributions, please read thecontributingguide.