| 1 |
Metadata-Version: 2.1 |
| 2 |
Name: nose2 |
| 3 |
Version: 0.15.1 |
| 4 |
Summary: unittest with plugins |
| 5 |
Author-email: Stephen Rosen <[email protected]> |
| 6 |
License: BSD-2-Clause |
| 7 |
Project-URL: changelog, https://docs.nose2.io/en/latest/changelog.html |
| 8 |
Project-URL: documentation, https://docs.nose2.io/ |
| 9 |
Project-URL: repository, https://github.com/nose-devs/nose2 |
| 10 |
Keywords: testing,tests,unittest |
| 11 |
Classifier: Development Status :: 4 - Beta |
| 12 |
Classifier: Environment :: Console |
| 13 |
Classifier: Intended Audience :: Developers |
| 14 |
Classifier: License :: OSI Approved :: BSD License |
| 15 |
Classifier: Operating System :: OS Independent |
| 16 |
Classifier: Programming Language :: Python |
| 17 |
Classifier: Programming Language :: Python :: 3 :: Only |
| 18 |
Classifier: Programming Language :: Python :: 3.8 |
| 19 |
Classifier: Programming Language :: Python :: 3.9 |
| 20 |
Classifier: Programming Language :: Python :: 3.10 |
| 21 |
Classifier: Programming Language :: Python :: 3.11 |
| 22 |
Classifier: Programming Language :: Python :: 3.12 |
| 23 |
Classifier: Programming Language :: Python :: Implementation :: CPython |
| 24 |
Classifier: Programming Language :: Python :: Implementation :: PyPy |
| 25 |
Classifier: Topic :: Software Development :: Libraries |
| 26 |
Classifier: Topic :: Software Development :: Libraries :: Python Modules |
| 27 |
Classifier: Topic :: Software Development :: Testing |
| 28 |
Requires-Python: >=3.8 |
| 29 |
Description-Content-Type: text/x-rst |
| 30 |
License-File: LICENSE |
| 31 |
License-File: AUTHORS |
| 32 |
Provides-Extra: coverage-plugin |
| 33 |
Requires-Dist: coverage; extra == "coverage-plugin" |
| 34 |
Provides-Extra: dev |
| 35 |
Requires-Dist: sphinx; extra == "dev" |
| 36 |
Requires-Dist: sphinx-issues; extra == "dev" |
| 37 |
Requires-Dist: sphinx-rtd-theme; extra == "dev" |
| 38 |
|
| 39 |
.. image:: https://results.pre-commit.ci/badge/github/nose-devs/nose2/main.svg |
| 40 |
:target: https://results.pre-commit.ci/latest/github/nose-devs/nose2/main |
| 41 |
:alt: pre-commit.ci status |
| 42 |
|
| 43 |
.. image:: https://github.com/nose-devs/nose2/workflows/build/badge.svg?event=push |
| 44 |
:alt: build status |
| 45 |
:target: https://github.com/nose-devs/nose2/actions?query=workflow%3Abuild |
| 46 |
|
| 47 |
.. image:: https://readthedocs.org/projects/nose2/badge/ |
| 48 |
:target: https://nose2.io/ |
| 49 |
:alt: Documentation |
| 50 |
|
| 51 |
.. image:: https://img.shields.io/pypi/v/nose2.svg |
| 52 |
:target: https://pypi.org/project/nose2/ |
| 53 |
:alt: Latest PyPI version |
| 54 |
|
| 55 |
.. image:: https://img.shields.io/pypi/pyversions/nose2.svg |
| 56 |
:alt: Supported Python Versions |
| 57 |
:target: https://pypi.org/project/nose2/ |
| 58 |
|
| 59 |
.. image:: https://img.shields.io/badge/Mailing%20list-discuss%40nose2.io-blue.svg |
| 60 |
:target: https://groups.google.com/a/nose2.io/forum/#!forum/discuss |
| 61 |
:alt: Join [email protected] |
| 62 |
|
| 63 |
Welcome to nose2 |
| 64 |
================ |
| 65 |
|
| 66 |
nose2's extends ``unittest`` to make testing nicer. |
| 67 |
|
| 68 |
nose2 vs nose |
| 69 |
------------- |
| 70 |
|
| 71 |
``nose2`` originated as the successor to ``nose``. |
| 72 |
|
| 73 |
``nose2`` is a distinct project and does not support all of the behaviors of ``nose``. |
| 74 |
See `differences`_ for a thorough rundown. |
| 75 |
|
| 76 |
nose2 vs pytest |
| 77 |
--------------- |
| 78 |
|
| 79 |
`pytest`_ is an excellent test framework and we encourage users to consider |
| 80 |
it for new projects. |
| 81 |
|
| 82 |
It has a bigger team of maintainers and a larger community of users. |
| 83 |
|
| 84 |
Quickstart |
| 85 |
---------- |
| 86 |
|
| 87 |
Because ``nose2`` is based on unittest, you can start from the Python Standard |
| 88 |
Library's `documentation for unittest <https://docs.python.org/library/unittest.html>`_ |
| 89 |
and then use nose2 to add value on top of that. |
| 90 |
|
| 91 |
``nose2`` looks for tests in Python files whose names start with ``test`` and |
| 92 |
runs every test function it discovers. |
| 93 |
|
| 94 |
Here's an example of a simple test, written in typical unittest style: |
| 95 |
|
| 96 |
.. code-block:: python |
| 97 |
|
| 98 |
# in test_simple.py |
| 99 |
import unittest |
| 100 |
|
| 101 |
class TestStrings(unittest.TestCase): |
| 102 |
def test_upper(self): |
| 103 |
self.assertEqual("spam".upper(), "SPAM") |
| 104 |
|
| 105 |
You can then run this test like so:: |
| 106 |
|
| 107 |
$ nose2 -v |
| 108 |
test_upper (test_simple.TestStrings) ... ok |
| 109 |
|
| 110 |
---------------------------------------------------------------------- |
| 111 |
Ran 1 test in 0.000s |
| 112 |
|
| 113 |
OK |
| 114 |
|
| 115 |
However, ``nose2`` supports more testing configuration and provides more tools |
| 116 |
than ``unittest`` on its own. |
| 117 |
|
| 118 |
For example, this test exercises just a few of ``nose2``'s features: |
| 119 |
|
| 120 |
.. code-block:: python |
| 121 |
|
| 122 |
# in test_fancy.py |
| 123 |
from nose2.tools import params |
| 124 |
|
| 125 |
@params("Sir Bedevere", "Miss Islington", "Duck") |
| 126 |
def test_is_knight(value): |
| 127 |
assert value.startswith('Sir') |
| 128 |
|
| 129 |
and then run this like so:: |
| 130 |
|
| 131 |
$ nose2 -v --pretty-assert |
| 132 |
test_fancy.test_is_knight:1 |
| 133 |
'Sir Bedevere' ... ok |
| 134 |
test_fancy.test_is_knight:2 |
| 135 |
'Miss Islington' ... FAIL |
| 136 |
test_fancy.test_is_knight:3 |
| 137 |
'Duck' ... FAIL |
| 138 |
|
| 139 |
====================================================================== |
| 140 |
FAIL: test_fancy.test_is_knight:2 |
| 141 |
'Miss Islington' |
| 142 |
---------------------------------------------------------------------- |
| 143 |
Traceback (most recent call last): |
| 144 |
File "/mnt/ebs/home/sirosen/tmp/test_fancy.py", line 6, in test_is_knight |
| 145 |
assert value.startswith('Sir') |
| 146 |
AssertionError |
| 147 |
|
| 148 |
>>> assert value.startswith('Sir') |
| 149 |
|
| 150 |
values: |
| 151 |
value = 'Miss Islington' |
| 152 |
value.startswith = <built-in method startswith of str object at 0x7f3c3172f430> |
| 153 |
====================================================================== |
| 154 |
FAIL: test_fancy.test_is_knight:3 |
| 155 |
'Duck' |
| 156 |
---------------------------------------------------------------------- |
| 157 |
Traceback (most recent call last): |
| 158 |
File "/mnt/ebs/home/sirosen/tmp/test_fancy.py", line 6, in test_is_knight |
| 159 |
assert value.startswith('Sir') |
| 160 |
AssertionError |
| 161 |
|
| 162 |
>>> assert value.startswith('Sir') |
| 163 |
|
| 164 |
values: |
| 165 |
value = 'Duck' |
| 166 |
value.startswith = <built-in method startswith of str object at 0x7f3c3172d490> |
| 167 |
---------------------------------------------------------------------- |
| 168 |
Ran 3 tests in 0.001s |
| 169 |
|
| 170 |
FAILED (failures=2) |
| 171 |
|
| 172 |
Full Docs |
| 173 |
--------- |
| 174 |
|
| 175 |
Full documentation for ``nose2`` is available at `docs.nose2.io`_ |
| 176 |
|
| 177 |
Versions and Support |
| 178 |
-------------------- |
| 179 |
|
| 180 |
Changelog and Version Scheme |
| 181 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 182 |
|
| 183 |
nose2 versions are numbered ``0.MAJOR.MINOR``. Minor releases contain bugfixes or |
| 184 |
smaller features. Major features or backwards incompatible changes are done in |
| 185 |
major releases. |
| 186 |
|
| 187 |
For a full description of all past versions and changes, see the `changelog`_. |
| 188 |
|
| 189 |
Python Versions |
| 190 |
~~~~~~~~~~~~~~~ |
| 191 |
|
| 192 |
nose2 requires Python 3. |
| 193 |
|
| 194 |
It supports all versions currently supported by the CPython team, and also aims |
| 195 |
to support PyPy and cpython betas. |
| 196 |
|
| 197 |
Python 2 |
| 198 |
******** |
| 199 |
|
| 200 |
Python 2 is no longer supported. The `0.12.x line of releases <py2line>`_ |
| 201 |
contains the last versions which supported Python 2. |
| 202 |
|
| 203 |
Users of Python 2 should understand that Python 2 is EOL and the Python 2 |
| 204 |
support line for ``nose2`` is similarly considered EOL. |
| 205 |
|
| 206 |
.. note:: |
| 207 |
|
| 208 |
Fixes to 0.12.x may still be accepted on an as-needed basis for a short |
| 209 |
while as the python3-only line of releases gets started. |
| 210 |
|
| 211 |
Contributing |
| 212 |
------------ |
| 213 |
|
| 214 |
If you want to make contributions, please read the `contributing`_ guide. |
| 215 |
|
| 216 |
.. _py2line: https://github.com/nose-devs/nose2/tree/0.12.x-line |
| 217 |
|
| 218 |
.. _differences: https://docs.nose2.io/en/latest/differences.html |
| 219 |
|
| 220 |
.. _changelog: https://docs.nose2.io/en/latest/changelog.html |
| 221 |
|
| 222 |
.. _pytest: http://pytest.readthedocs.io/en/latest/ |
| 223 |
|
| 224 |
.. _contributing: https://github.com/nose-devs/nose2/blob/main/contributing.rst |
| 225 |
|
| 226 |
.. _docs.nose2.io: https://docs.nose2.io/en/latest/ |