|
3 | 3 |
|
4 | 4 | **Incompatible changes**
|
5 | 5 |
|
6 |
| -* Removed the following deprecated commandline options |
| 6 | +A number of incompatible changes were made in this release, with the intent of removing features deprecated for a long |
| 7 | +time or change existing behaviors in order to make them less surprising/more useful. |
7 | 8 |
|
8 |
| - * ``--genscript`` |
9 |
| - * ``--no-assert`` |
10 |
| - * ``--nomagic`` |
11 |
| - * ``--report`` |
| 9 | +* The following deprecated commandline options were removed: |
12 | 10 |
|
13 |
| - Thanks to `@RedBeardCode`_ for the PR (`#1664`_) |
| 11 | + * ``--genscript``: no longer supported; |
| 12 | + * ``--no-assert``: use ``--assert=plain`` instead; |
| 13 | + * ``--nomagic``: use ``--assert=plain`` instead; |
| 14 | + * ``--report``: use ``-r`` instead; |
| 15 | + |
| 16 | + Thanks to `@RedBeardCode`_ for the PR (`#1664`_). |
14 | 17 |
|
15 | 18 | * ImportErrors in plugins now are a fatal error instead of issuing a
|
16 | 19 | pytest warning (`#1479`_). Thanks to `@The-Compiler`_ for the PR.
|
17 | 20 |
|
18 |
| -* removed support code for python 3 < 3.3 addressing (`#1627`_) |
| 21 | +* Removed support code for Python 3 versions < 3.3 (`#1627`_). |
19 | 22 |
|
20 |
| -* Remove all py.test-X* entry points. The versioned, suffixed entry points |
| 23 | +* Removed all ``py.test-X*`` entry points. The versioned, suffixed entry points |
21 | 24 | were never documented and a leftover from a pre-virtualenv era. These entry
|
22 | 25 | points also created broken entry points in wheels, so removing them also
|
23 | 26 | removes a source of confusion for users (`#1632`_).
|
24 | 27 | Thanks `@obestwalter`_ for the PR.
|
25 | 28 |
|
26 |
| -* Fix `#607`_: pytest.skip() is no longer allowed at module level to |
27 |
| - prevent misleading use as test function decorator. When used at a module |
28 |
| - level an error will be raised during collection. |
| 29 | +* ``pytest.skip()`` now raises an error when used to decorate a test function, |
| 30 | + as opposed to its original intent (to imperatively skip a test inside a test function). Previously |
| 31 | + this usage would cause the entire module to be skipped (`#607`_). |
29 | 32 | Thanks `@omarkohl`_ for the complete PR (`#1519`_).
|
30 | 33 |
|
31 |
| -* Fix `#1421`_: Exit tests if a collection error occurs and add |
32 |
| - ``--continue-on-collection-errors`` option to restore previous behaviour. |
| 34 | +* Exit tests if a collection error occurs. A poll indicated most users will hit CTRL-C |
| 35 | + anyway as soon as they see collection errors, so pytest might as well make that the default behavior (`#1421`_). |
| 36 | + A ``--continue-on-collection-errors`` option has been added to restore the previous behaviour. |
33 | 37 | Thanks `@olegpidsadnyi`_ and `@omarkohl`_ for the complete PR (`#1628`_).
|
34 | 38 |
|
35 |
| -* Renamed the pytest ``pdb`` module (plugin) into ``debugging``. |
| 39 | +* Renamed the pytest ``pdb`` module (plugin) into ``debugging`` to avoid clashes with the builtin ``pdb`` module. |
36 | 40 |
|
37 |
| -* Raise helpful failure message, when requesting parametrized fixture at runtime, |
38 |
| - e.g. with ``request.getfuncargvalue``. Previously these params were simply |
39 |
| - never defined. So a fixture decorated like ``@pytest.fixture(params=[0, 1, |
40 |
| - 2])`` only ran once. Now a failure is raised. Fixes `#460`_. Thanks to |
41 |
| - `@nikratio`_ for bug report, `@RedBeardCode`_ and `@tomviner`_ for PR. |
| 41 | +* Raise a helpful failure message when requesting a parametrized fixture at runtime, |
| 42 | + e.g. with ``request.getfixturevalue``. Previously these parameters were simply |
| 43 | + never defined, so a fixture decorated like ``@pytest.fixture(params=[0, 1, 2])`` |
| 44 | + only ran once (`#460`_). |
| 45 | + Thanks to `@nikratio`_ for the bug report, `@RedBeardCode`_ and `@tomviner`_ for the PR. |
42 | 46 |
|
43 | 47 | * ``_pytest.monkeypatch.monkeypatch`` class has been renamed to ``_pytest.monkeypatch.MonkeyPatch``
|
44 | 48 | so it doesn't conflict with the ``monkeypatch`` fixture.
|
|
54 | 58 | **New Features**
|
55 | 59 |
|
56 | 60 | * Support nose-style ``__test__`` attribute on methods of classes,
|
57 |
| - including unittest-style Classes. If set to False, the test will not be |
| 61 | + including unittest-style Classes. If set to ``False``, the test will not be |
58 | 62 | collected.
|
59 | 63 |
|
60 | 64 | * New ``doctest_namespace`` fixture for injecting names into the
|
61 |
| - namespace in which your doctests run. |
| 65 | + namespace in which doctests run. |
62 | 66 | Thanks `@milliams`_ for the complete PR (`#1428`_).
|
63 | 67 |
|
64 |
| -* New ``name`` argument to ``pytest.fixture`` mark, which allows a custom name |
| 68 | +* New ``name`` argument to ``pytest.fixture`` decorator which allows a custom name |
65 | 69 | for a fixture (to solve the funcarg-shadowing-fixture problem).
|
66 | 70 | Thanks `@novas0x2a`_ for the complete PR (`#1444`_).
|
67 | 71 |
|
68 | 72 | * New ``approx()`` function for easily comparing floating-point numbers in
|
69 | 73 | tests.
|
70 | 74 | Thanks `@kalekundert`_ for the complete PR (`#1441`_).
|
71 | 75 |
|
72 |
| -* New Add ability to add global properties in the final xunit output file. |
| 76 | +* Ability to add global properties in the final xunit output file by accessing |
| 77 | + the internal ``junitxml`` plugin (experimental). |
73 | 78 | Thanks `@tareqalayan`_ for the complete PR `#1454`_).
|
74 | 79 |
|
75 | 80 | * New ``ExceptionInfo.match()`` method to match a regular expression on the
|
76 |
| - string representation of an exception. Closes proposal `#372`_. |
77 |
| - Thanks `@omarkohl`_ for the complete PR (`#1502`_) and `@nicoddemus`_ for the |
78 |
| - implementation tips. |
| 81 | + string representation of an exception (`#372`_). |
| 82 | + Thanks `@omarkohl`_ for the complete PR (`#1502`_). |
79 | 83 |
|
80 | 84 | * ``__tracebackhide__`` can now also be set to a callable which then can decide
|
81 | 85 | whether to filter the traceback based on the ``ExceptionInfo`` object passed
|
82 | 86 | to it. Thanks `@The-Compiler`_ for the complete PR (`#1526`_).
|
83 | 87 |
|
84 |
| -* New ``pytest_make_parametrize_id`` hook. |
| 88 | +* New ``pytest_make_parametrize_id(config, val)`` hook which can be used by plugins to provide |
| 89 | + friendly strings for custom types. |
85 | 90 | Thanks `@palaviv`_ for the PR.
|
86 | 91 |
|
87 |
| -* ``capsys`` and ``capfd`` now have a ``disabled()`` method, which is a context manager |
88 |
| - that can be used to temporarily disable capture within a test. |
| 92 | +* ``capsys`` and ``capfd`` now have a ``disabled()`` context-manager method, which |
| 93 | + can be used to temporarily disable capture within a test. |
89 | 94 | Thanks `@nicoddemus`_ for the PR.
|
90 | 95 |
|
91 |
| -* New cli flag ``--fixtures-per-test`` that shows which fixtures are being used |
| 96 | +* New cli flag ``--fixtures-per-test``: shows which fixtures are being used |
92 | 97 | for each selected test item. Features doc strings of fixtures by default.
|
93 | 98 | Can also show where fixtures are defined if combined with ``-v``.
|
94 | 99 | Thanks `@hackebrot`_ for the PR.
|
95 | 100 |
|
96 |
| -* Introduce pytest command as recommended entry point. Closes proposal |
| 101 | +* Introduce ``pytest`` command as recommended entry point. Note that ``py.test`` |
| 102 | + still works and is not scheduled for removal. Closes proposal |
97 | 103 | `#1629`_. Thanks `@obestwalter`_ and `@davehunt`_ for the complete PR
|
98 |
| - (`#1633`_) |
| 104 | + (`#1633`_). |
| 105 | + |
| 106 | +* New cli flags: |
| 107 | + |
| 108 | + + ``--setup-plan``: performs normal collection and reports |
| 109 | + the potential setup and teardown and does not execute any fixtures and tests; |
| 110 | + + ``--setup-only``: performs normal collection, executes setup and teardown of |
| 111 | + fixtures and reports them; |
| 112 | + + ``--setup-show``: performs normal test execution and additionally shows |
| 113 | + setup and teardown of fixtures; |
99 | 114 |
|
100 |
| -* New cli flags: (1) ``--setup-plan`` performs normal collection and reports |
101 |
| - the potential setup and teardown, does not execute any fixtures and tests (2) |
102 |
| - ``--setup-only`` performs normal collection, executes setup and teardown of |
103 |
| - fixtures and reports them. (3) ``--setup-show`` performs normal test |
104 |
| - execution and additionally shows the setup and teardown of fixtures. |
105 | 115 | Thanks `@d6e`_, `@kvas-it`_, `@sallner`_ and `@omarkohl`_ for the PRs.
|
106 | 116 |
|
107 |
| -* Added two new hooks: ``pytest_fixture_setup`` which executes the fixture |
108 |
| - setup and ``pytest_fixture_post_finalizer`` which is called after the fixture's |
109 |
| - finalizer and has access to the fixture's result cache. |
110 |
| - Thanks `@d6e`_, `@sallner`_ |
| 117 | +* New cli flag ``--override-ini``/``-o``: overrides values from the ini file. |
| 118 | + For example: ``"-o xfail_strict=True"``'. |
| 119 | + Thanks `@blueyed`_ and `@fengxx`_ for the PR. |
| 120 | + |
| 121 | +* New hooks: |
| 122 | + |
| 123 | + + ``pytest_fixture_setup(fixturedef, request)``: executes fixture setup; |
| 124 | + + ``pytest_fixture_post_finalizer(fixturedef)``: called after the fixture's |
| 125 | + finalizer and has access to the fixture's result cache. |
| 126 | + |
| 127 | + Thanks `@d6e`_, `@sallner`_. |
111 | 128 |
|
112 |
| -* Issue a warning for asserts whose test is a tuple literal. Such asserts will |
| 129 | +* Issue warnings for asserts whose test is a tuple literal. Such asserts will |
113 | 130 | never fail because tuples are always truthy and are usually a mistake
|
114 | 131 | (see `#1562`_). Thanks `@kvas-it`_, for the PR.
|
115 | 132 |
|
116 |
| -* New cli flag ``--override-ini`` or ``-o`` that overrides values from the ini file. |
117 |
| - Example '-o xfail_strict=True'. A complete ini-options can be viewed |
118 |
| - by py.test --help. Thanks `@blueyed`_ and `@fengxx`_ for the PR |
119 |
| - |
120 |
| -* Allow passing a custom debugger class (e.g. ``IPython.core.debugger:Pdb`` |
121 |
| - via ``--pdbcls``). Thanks to `@anntzer`_ for the PR. |
| 133 | +* Allow passing a custom debugger class (e.g. ``--pdbcls=IPython.core.debugger:Pdb``). |
| 134 | + Thanks to `@anntzer`_ for the PR. |
122 | 135 |
|
123 | 136 | *
|
124 | 137 |
|
|
136 | 149 | the preferred way to write teardown code (`#1461`_).
|
137 | 150 | Thanks `@csaftoiu`_ for bringing this to attention and `@nicoddemus`_ for the PR.
|
138 | 151 |
|
139 |
| -* Fix `#1351`_: |
140 |
| - explicitly passed parametrize ids do not get escaped to ascii. |
| 152 | +* Explicitly passed parametrize ids do not get escaped to ascii (`#1351`_). |
141 | 153 | Thanks `@ceridwen`_ for the PR.
|
142 | 154 |
|
143 |
| -* parametrize ids can accept None as specific test id. The |
| 155 | +* Parametrize ids can accept ``None`` as specific test id, in which case the |
144 | 156 | automatically generated id for that argument will be used.
|
145 | 157 | Thanks `@palaviv`_ for the complete PR (`#1468`_).
|
146 | 158 |
|
147 |
| -* improved idmaker name selection in case of duplicate ids in |
| 159 | +* Improved automatic id generation selection in case of duplicate ids in |
148 | 160 | parametrize.
|
149 | 161 | Thanks `@palaviv`_ for the complete PR (`#1474`_).
|
150 | 162 |
|
151 |
| -* Fix `#1426`_ Make ImportError during collection more explicit by reminding |
152 |
| - the user to check the name of the test module/package(s). |
| 163 | +* Make ImportError during collection more explicit by reminding |
| 164 | + the user to check the name of the test module/package(s) (`#1426`_). |
153 | 165 | Thanks `@omarkohl`_ for the complete PR (`#1520`_).
|
154 | 166 |
|
155 | 167 | * Add ``build/`` and ``dist/`` to the default ``--norecursedirs`` list. Thanks
|
156 | 168 | `@mikofski`_ for the report and `@tomviner`_ for the PR (`#1544`_).
|
157 | 169 |
|
158 |
| -* pytest.raises in the context manager form accepts a custom |
159 |
| - message to raise when no exception occurred. |
| 170 | +* ``pytest.raises`` in the context manager form accepts a custom |
| 171 | + ``message`` to raise when no exception occurred. |
160 | 172 | Thanks `@palaviv`_ for the complete PR (`#1616`_).
|
161 | 173 |
|
162 | 174 | * ``conftest.py`` files now benefit from assertion rewriting; previously it
|
|
170 | 182 | is specified on the command line together with the ``--pyargs``
|
171 | 183 | option. Thanks to `@taschini`_ for the PR (`#1597`_).
|
172 | 184 |
|
173 |
| -* Add proposal to docs for a new feature that enables users to combine multiple |
174 |
| - fixtures into one. Thanks to `@hpk42`_ and `@hackebrot`_. |
175 |
| - |
176 |
| -* Rename ``getfuncargvalue`` to ``getfixturevalue``. ``getfuncargvalue`` is |
177 |
| - deprecated but still present. Thanks to `@RedBeardCode`_ and `@tomviner`_ |
178 |
| - for PR (`#1626`_). |
179 |
| - |
180 |
| -* Always include full assertion explanation. The previous behaviour was hiding |
181 |
| - sub-expressions that happened to be False, assuming this was redundant information. |
| 185 | +* Always include full assertion explanation during assertion rewriting. The previous behaviour was hiding |
| 186 | + sub-expressions that happened to be ``False``, assuming this was redundant information. |
182 | 187 | Thanks `@bagerard`_ for reporting (`#1503`_). Thanks to `@davehunt`_ and
|
183 |
| - `@tomviner`_ for PR. |
| 188 | + `@tomviner`_ for the PR. |
184 | 189 |
|
185 | 190 | * ``OptionGroup.addoption()`` now checks if option names were already
|
186 | 191 | added before, to make it easier to track down issues like `#1618`_.
|
|
194 | 199 | removed in pytest-4.0 (`#1684`_).
|
195 | 200 | Thanks `@nicoddemus`_ for the PR.
|
196 | 201 |
|
| 202 | +* Rename ``getfuncargvalue`` to ``getfixturevalue``. ``getfuncargvalue`` is |
| 203 | + still present but is now considered deprecated. Thanks to `@RedBeardCode`_ and `@tomviner`_ |
| 204 | + for the PR (`#1626`_). |
| 205 | + |
197 | 206 | *
|
198 | 207 |
|
199 | 208 | *
|
|
202 | 211 |
|
203 | 212 | **Bug Fixes**
|
204 | 213 |
|
205 |
| -* When receiving identical test ids in parametrize we generate unique test ids. |
| 214 | +* Parametrize now correctly handles duplicated test ids. |
206 | 215 |
|
207 |
| -* Fix internal error issue when ``method`` argument is missing for |
208 |
| - ``teardown_method()``. Fixes `#1605`_. |
| 216 | +* Fix internal error issue when the ``method`` argument is missing for |
| 217 | + ``teardown_method()`` (`#1605`_). |
209 | 218 |
|
210 | 219 | * Fix exception visualization in case the current working directory (CWD) gets
|
211 |
| - deleted during testing. Fixes `#1235`_. Thanks `@bukzor`_ for reporting. PR by |
212 |
| - `@marscher`_. Thanks `@nicoddemus`_ for his help. |
| 220 | + deleted during testing (`#1235`_). Thanks `@bukzor`_ for reporting. PR by |
| 221 | + `@marscher`_. |
213 | 222 |
|
214 |
| -* Improve of the test output for logical expression with brackets. |
215 |
| - Fixes `#925`_. Thanks `@DRMacIver`_ for reporting. Thanks to `@RedBeardCode`_ |
216 |
| - for PR. |
| 223 | +* Improve test output for logical expression with brackets (`#925`_). |
| 224 | + Thanks `@DRMacIver`_ for reporting and `@RedBeardCode`_ for the PR. |
217 | 225 |
|
218 |
| -* Create correct diff for strings ending with newlines. Fixes `#1553`_. |
219 |
| - Thanks `@Vogtinator`_ for reporting. Thanks to `@RedBeardCode`_ and |
220 |
| - `@tomviner`_ for PR. |
| 226 | +* Create correct diff for strings ending with newlines (`#1553`_). |
| 227 | + Thanks `@Vogtinator`_ for reporting and `@RedBeardCode`_ and |
| 228 | + `@tomviner`_ for the PR. |
221 | 229 |
|
222 | 230 | *
|
223 | 231 |
|
|
0 commit comments