Debian Codegraph @

README.rst

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