Debian Codegraph @

doc/en/changelog.rst

raw
1 .. _`changelog`:
2
3 =========
4 Changelog
5 =========
6
7 Versions follow `Semantic Versioning <https://semver.org/>`_ (``<major>.<minor>.<patch>``).
8
9 Backward incompatible (breaking) changes will only be introduced in major versions
10 with advance notice in the **Deprecations** section of releases.
11
12
13 ..
14 You should *NOT* be adding new change log entries to this file, this
15 file is managed by towncrier. You *may* edit previous change logs to
16 fix problems like typo corrections or such.
17 To add a new change log entry, please see
18 https://pip.pypa.io/en/latest/development/contributing/#news-entries
19 but note that in pytest the "news/" directory is named "changelog/".
20
21
22 .. only:: not is_release
23
24 To be included in v\ |release| (if present)
25 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
26
27 .. towncrier-draft-entries:: |release| [UNRELEASED DRAFT]
28
29 Released versions
30 ^^^^^^^^^^^^^^^^^
31
32 .. towncrier release notes start
33
34 pytest 9.1.1 (2026-06-19)
35 =========================
36
37 Bug fixes
38 ---------
39
40 - `#14220 <https://github.com/pytest-dev/pytest/issues/14220>`_: Fixed a logic bug in :class:`pytest.RaisesGroup` which would might cause it to display incorrect "It matches `FooError()` which was paired with `BarError`" messages.
41
42
43 - `#14591 <https://github.com/pytest-dev/pytest/issues/14591>`_: Fixed a regression in pytest 9.1.0 which caused overriding a parametrized fixture with an indirect `@pytest.mark.parametrize` to fail with "duplicate parametrization of '<fixture name>'".
44
45
46 - `#14606 <https://github.com/pytest-dev/pytest/issues/14606>`_: Fixed ``list-item`` typing errors from mypy in :ref:`@pytest.mark.parametrize <pytest.mark.parametrize ref>` ``argvalues`` parameter.
47
48
49 - `#14608 <https://github.com/pytest-dev/pytest/issues/14608>`_: Fixed a regression in pytest 9.1.0 where ``conftest.py`` files located in ``<invocation dir>/test*`` were no longer loaded as initial conftests when invoked without arguments.
50 This could cause certain hooks (like :hook:`pytest_addoption`) in these files to not fire.
51
52
53 pytest 9.1.0 (2026-06-13)
54 =========================
55
56 Removals and backward incompatible breaking changes
57 ---------------------------------------------------
58
59 - `#14533 <https://github.com/pytest-dev/pytest/issues/14533>`_: When using :option:`--doctest-modules`, autouse fixtures with ``module``, ``package`` or ``session`` scope that are defined inline in Python test modules (not plugins or conftests) will now possibly execute twice.
60
61 If this is undesirable, move the fixture definition to a ``conftest.py`` file if possible.
62
63 Technical explanation for those interested:
64 When using `--doctest-modules`, pytest possibly collects Python modules twice, once as :class:`pytest.Module` and once as a ``DoctestModule`` (depending on the configuration).
65 Due to improvements in pytest's fixture implementation, if e.g. the ``DoctestModule`` collects a fixture, it is now visible to it only, and not to the ``Module``.
66 This means that both need to register the fixtures independently.
67
68
69
70 Deprecations (removal in next major release)
71 --------------------------------------------
72
73 - `#10819 <https://github.com/pytest-dev/pytest/issues/10819>`_: Added a deprecation warning for class-scoped fixtures defined as instance methods (without ``@classmethod``). Such fixtures set attributes on a different instance than the test methods use, leading to unexpected behavior. Use ``@classmethod`` decorator instead -- by :user:`yastcher`.
74
75 See :issue:`10819` and :issue:`14011`.
76
77
78 - `#12882 <https://github.com/pytest-dev/pytest/issues/12882>`_: Calling :meth:`request.getfixturevalue() <pytest.FixtureRequest.getfixturevalue>` during teardown to request a fixture that was not already requested is now deprecated and will become an error in pytest 10.
79
80 See :ref:`dynamic-fixture-request-during-teardown` for details.
81
82
83 - `#13409 <https://github.com/pytest-dev/pytest/issues/13409>`_: Using non-:class:`~collections.abc.Collection` iterables (such as generators, iterators, or custom iterable objects) for the ``argvalues`` parameter in :ref:`@pytest.mark.parametrize <pytest.mark.parametrize ref>` and :meth:`metafunc.parametrize <pytest.Metafunc.parametrize>` is now deprecated.
84
85 These iterables get exhausted after the first iteration,
86 leading to tests getting unexpectedly skipped in cases such as running :func:`pytest.main()` multiple times,
87 using class-level parametrize decorators,
88 or collecting tests multiple times.
89
90 See :ref:`parametrize-iterators` for details and suggestions.
91
92
93 - `#13946 <https://github.com/pytest-dev/pytest/issues/13946>`_: The private ``config.inicfg`` attribute is now deprecated.
94 Use :meth:`config.getini() <pytest.Config.getini>` to access configuration values instead.
95
96 See :ref:`config-inicfg` for more details.
97
98
99 - `#14004 <https://github.com/pytest-dev/pytest/issues/14004>`_: Passing ``baseid`` to :class:`~pytest.FixtureDef` or ``nodeid`` strings to fixture registration APIs is now deprecated. These are internal pytest APIs that are used by some plugins.
100
101 Use the ``node`` parameter instead for fixture scoping. This enables more robust node-based
102 matching instead of string prefix matching.
103 If you've used ``nodeid=None``, pass ``node=session`` instead.
104
105 This will be removed in pytest 10.
106
107
108 - `#14335 <https://github.com/pytest-dev/pytest/issues/14335>`_: The method of configuring hooks using markers, deprecated since pytest 7.2, is now scheduled to be removed in pytest 10.
109 See :ref:`hook-markers` for more details.
110
111
112 - `#14434 <https://github.com/pytest-dev/pytest/issues/14434>`_: The :option:`--pastebin` option is now deprecated.
113 The same functionality is now available in an external plugin, :pypi:`pytest-pastebin`.
114 See :ref:`pastebin-deprecated` for more details.
115
116
117 - `#14513 <https://github.com/pytest-dev/pytest/issues/14513>`_: The private ``FixtureDef.has_location`` attribute is now deprecated and will be removed in pytest 10.
118 See :ref:`fixturedef-has-location-deprecated` for details.
119
120
121 - `#1764 <https://github.com/pytest-dev/pytest/issues/1764>`_: :func:`pytest.console_main` is now deprecated and will be removed in pytest 10.
122 It was never intended for programmatic use; use :func:`pytest.main` instead.
123
124
125
126 New features
127 ------------
128
129 - `#12376 <https://github.com/pytest-dev/pytest/issues/12376>`_: Added :func:`pytest.register_fixture()` to register fixtures using an imperative interface.
130
131 This is an advanced function intended for use by plugins.
132
133 Normally, fixtures should be registered declaratively using the :func:`@pytest.fixture <pytest.fixture>` decorator.
134 Pytest looks for these fixture definitions during the collection phase and registers them automatically.
135 For some plugin usecases the declarative interface can be cumbersome or unviable, in which case this imperative interface can be used.
136
137
138 - `#14023 <https://github.com/pytest-dev/pytest/issues/14023>`_: Added `--report-chars` long CLI option.
139
140
141 - `#14371 <https://github.com/pytest-dev/pytest/issues/14371>`_: Added :option:`--max-warnings` command-line option and :confval:`max_warnings` configuration option to fail the test run when the number of warnings exceeds a given threshold -- by :user:`miketheman`.
142
143
144 - `#6757 <https://github.com/pytest-dev/pytest/issues/6757>`_: Added the :confval:`assertion_text_diff_style` configuration option, allowing
145 string equality failures to be rendered as separate ``Left:`` and ``Right:``
146 blocks instead of ``ndiff`` output.
147
148
149 - `#8395 <https://github.com/pytest-dev/pytest/issues/8395>`_: Added support for :class:`~datetime.datetime` and :class:`~datetime.timedelta` comparisons with :func:`pytest.approx`. An explicit ``abs`` or ``rel`` tolerance as a :class:`~datetime.timedelta` is required and relative tolerance is not supported for datetime comparisons -- by :user:`hamza-mobeen`.
150
151
152
153 Improvements in existing functionality
154 --------------------------------------
155
156 - `#11225 <https://github.com/pytest-dev/pytest/issues/11225>`_: :func:`pytest.warns` now shows "Regex pattern did not match" instead of "DID NOT WARN" when warnings were emitted but the ``match`` pattern did not match.
157
158
159 - `#11295 <https://github.com/pytest-dev/pytest/issues/11295>`_: Improved output of ``--fixtures-per-test`` by excluding internal-implementation fixtures generated by ``@pytest.mark.parametrize`` and similar.
160
161
162 - `#13241 <https://github.com/pytest-dev/pytest/issues/13241>`_: :func:`pytest.raises`, :func:`pytest.warns` and :func:`pytest.deprecated_call` now uses :class:`ParamSpec` for the type hint to the (old and not recommended) callable overload, instead of :class:`Any`. This allows type checkers to raise errors when passing incorrect function parameters.
163 ``func`` can now also be passed as a kwarg, which the type hint previously showed as possible but didn't accept.
164
165
166 - `#13862 <https://github.com/pytest-dev/pytest/issues/13862>`_: Improved the readability of "DID NOT RAISE" error messages by using the exception type's name instead of its `repr`.
167
168
169 - `#14026 <https://github.com/pytest-dev/pytest/issues/14026>`_: Added test coverage for compiled regex patterns in :func:`pytest.raises` match parameter.
170
171
172 - `#14137 <https://github.com/pytest-dev/pytest/issues/14137>`_: `pytest.ScopeName` is now public to allow using it in function signatures.
173
174
175 - `#14342 <https://github.com/pytest-dev/pytest/issues/14342>`_: Marked ``yield_fixture`` as deprecated to type checkers using the ``deprecated`` decorator. Note it
176 :ref:`has originally been deprecated <yield-fixture-deprecated>` in pytest 6.2 already.
177
178
179 - `#14373 <https://github.com/pytest-dev/pytest/issues/14373>`_: Added type annotations for :func:`pytest.approx`.
180
181
182 - `#14430 <https://github.com/pytest-dev/pytest/issues/14430>`_: When using ``--setup-show``, a space is now printed after the test name (and possibly used fixtures), to separate it from the test result.
183
184
185 - `#14441 <https://github.com/pytest-dev/pytest/issues/14441>`_: Reduced the default number of ``gc.collect()`` passes in the ``unraisableexception`` plugin from 5 to 1 on CPython, where reference counting makes a single pass sufficient. PyPy retains 5 passes due to object resurrection via ``__del__``. This can noticeably speed up test suites that trigger many pytester runs.
186
187
188 - `#14461 <https://github.com/pytest-dev/pytest/issues/14461>`_: Improved assertion failure explanations for equality comparisons between mapping objects that are not ``dict`` instances.
189
190
191 - `#14513 <https://github.com/pytest-dev/pytest/issues/14513>`_: The order in which fixture definitions overriding each other are resolved is now determined first by their *visibility* in the collection tree rather than by the order in which they are registered.
192
193 A fixture defined for a more specific node (e.g. a module or an item) now always takes precedence over one with the same name defined for a more general node (e.g. the session), even when the more general one was registered later.
194 Fixtures with non-comparable visibility or the same visibility keep the existing behavior of "last registered wins".
195 This change is supposed to only affect plugins which register multiple fixtures programmatically with the same name.
196
197
198 - `#14524 <https://github.com/pytest-dev/pytest/issues/14524>`_: Add official Python 3.15 support.
199
200
201 - `#1764 <https://github.com/pytest-dev/pytest/issues/1764>`_: Improved argparse program name to show ``pytest``, ``python -m pytest``, or ``pytest.main()`` based on how pytest was invoked, making help and error messages clearer.
202
203
204 - `#8265 <https://github.com/pytest-dev/pytest/issues/8265>`_: Emit a ``PytestCollectionWarning`` when a module-level ``__getattr__`` returns ``None`` for ``pytestmark`` instead of raising ``AttributeError``.
205
206 Previously this caused a cryptic ``TypeError: got None instead of Mark`` error.
207 Now pytest issues a helpful warning and continues collecting the module normally.
208
209
210
211 Bug fixes
212 ---------
213
214 - `#13192 <https://github.com/pytest-dev/pytest/issues/13192>`_: Fixed `|` (pipe) not being treated as a regex meta-character that needs escaping in :func:`pytest.raises(match=...) <pytest.raises>`.
215
216
217 - `#13484 <https://github.com/pytest-dev/pytest/issues/13484>`_: Fixed ``-W`` option values being duplicated in ``Config.known_args_namespace``.
218
219
220 - `#13626 <https://github.com/pytest-dev/pytest/issues/13626>`_: Fixed function-scoped fixture values being kept alive after a test was interrupted by ``KeyboardInterrupt`` or early exit,
221 allowing them to potentially be released more promptly.
222
223
224 - `#13784 <https://github.com/pytest-dev/pytest/issues/13784>`_: Fixed ``capteesys`` producing doubled output when used with ``--capture=no`` (``-s``).
225
226
227 - `#13817 <https://github.com/pytest-dev/pytest/issues/13817>`_: Fixed a secondary `AttributeError` masking the original error when an option argument fails to initialize.
228
229
230 - `#13884 <https://github.com/pytest-dev/pytest/issues/13884>`_: Fixed rare internal IndexError caused by `builtins.compile` being overridden in client code.
231
232
233 - `#13885 <https://github.com/pytest-dev/pytest/issues/13885>`_: Fixed autouse fixtures defined inside a :class:`unittest.TestCase` class running even when the class is decorated with :func:`unittest.skip` or :func:`unittest.skipIf` -- regression since pytest 8.1.0.
234
235
236 - `#13917 <https://github.com/pytest-dev/pytest/issues/13917>`_: :class:`unittest.SkipTest` is no longer considered an interactive exception, i.e. :hook:`pytest_exception_interact` is no longer called for it.
237
238
239 - `#13963 <https://github.com/pytest-dev/pytest/issues/13963>`_: Fixed subtests running with :pypi:`pytest-xdist` when their contexts contain objects that are not JSON-serializable.
240
241 Fixes `pytest-dev/pytest-xdist#1273 <https://github.com/pytest-dev/pytest-xdist/issues/1273>`__.
242
243
244 - `#14004 <https://github.com/pytest-dev/pytest/issues/14004>`_: Fixed conftest.py fixture scoping when :confval:`testpaths` points outside of the :ref:`rootdir <rootdir>`.
245
246 Previously, fixtures from nested conftest.py files would incorrectly leak to sibling directories
247 when using a relative ``testpaths`` like ``../tests/sdk``.
248
249 Conftest fixtures are now parsed during :class:`Directory <pytest.Directory>` collection, using the ``Directory`` node for proper scoping.
250
251
252 - `#14050 <https://github.com/pytest-dev/pytest/issues/14050>`_: Display dictionary differences in assertion failures using the original key insertion order instead of sorted order.
253
254
255 - `#14080 <https://github.com/pytest-dev/pytest/issues/14080>`_: fix missing type annotations on ``Pytester.makepyfile`` and ``Pytester.maketxtfile`` methods.
256
257
258 - `#14114 <https://github.com/pytest-dev/pytest/issues/14114>`_: An exception from :hook:`pytest_fixture_post_finalizer` no longer prevents fixtures from being torn down, causing additional errors in the following tests.
259
260
261 - `#14161 <https://github.com/pytest-dev/pytest/issues/14161>`_: Fixed :meth:`monkeypatch.setattr() <pytest.MonkeyPatch.setattr>` leaving a stale entry on the undo stack when the underlying ``setattr()`` call fails (e.g. on immutable targets), causing an ``AttributeError`` crash during teardown.
262
263
264 - `#14214 <https://github.com/pytest-dev/pytest/issues/14214>`_: Fixed ``-v`` hint in :func:`pytest.raises` match diff not working because assertion verbosity was not propagated.
265
266
267 - `#14234 <https://github.com/pytest-dev/pytest/issues/14234>`_: Allow :ref:`pytest.HIDDEN_PARAM <hidden-param>` in :ref:`@pytest.mark.parametrize(ids=...) <pytest.mark.parametrize ref>` typing.
268
269
270 - `#14248 <https://github.com/pytest-dev/pytest/issues/14248>`_: Fixed direct parametrization causing the static fixture closure (as reflected in :data:`request.fixturenames <pytest.FixtureRequest.fixturenames>`) to omit fixtures that are requested transitively from overridden fixtures.
271
272
273 - `#14263 <https://github.com/pytest-dev/pytest/issues/14263>`_: Unraisable exceptions from finalizers are now collected during ``pytest_unconfigure``, before pytest tears down the warning filters installed for the session. Previously the collection ran from a cleanup callback whose order relative to other plugins' cleanups was not guaranteed, so an active ``error`` filter could be removed before the exception surfaced and a late resource leak would pass silently. A ``-W error`` filter, or any filter matching :class:`pytest.PytestUnraisableExceptionWarning`, now promotes these exceptions to failures regardless of plugin cleanup order.
274
275
276 - `#14377 <https://github.com/pytest-dev/pytest/issues/14377>`_: Fixed crash in `Config.get_terminal_writer` when an assertion fails with the ``terminalreporter`` plugin disabled.
277
278
279 - `#14381 <https://github.com/pytest-dev/pytest/issues/14381>`_: Fixed ``-V`` (short form of ``--version``) to properly display the current version.
280
281
282 - `#14389 <https://github.com/pytest-dev/pytest/issues/14389>`_: Improved :func:`pytest.raises(..., match=...) <pytest.raises>` failures to suppress the mismatched exception as a cause of the resulting ``AssertionError``.
283
284
285 - `#14392 <https://github.com/pytest-dev/pytest/issues/14392>`_: Fixed a bug in :func:`pytest.raises(match=...) <pytest.raises>` "fully escaped" detection, causing the regex diff display to be shown in some instances when the raw string diff display should be shown instead.
286
287
288 - `#14442 <https://github.com/pytest-dev/pytest/issues/14442>`_: Fixed a regression in pytest 9.0 where :option:`--strict-markers` and :option:`--strict-config` specified through :confval:`addopts` were silently ignored.
289
290 Note that when targeting pytest >= 9.0, it's nicer to use :confval:`strict_markers` and :confval:`strict_config`, or :ref:`strict mode <strict mode>`.
291
292
293 - `#14456 <https://github.com/pytest-dev/pytest/issues/14456>`_: Fixed :func:`pytest.approx` not recognizing types with ``__array_interface__`` as numpy-like arrays.
294
295
296 - `#14474 <https://github.com/pytest-dev/pytest/issues/14474>`_: Fixed a regression where ``-k`` and ``-m`` expressions containing both backslash characters in identifiers and string literal arguments would incorrectly raise a ``SyntaxError`` about escaping.
297
298
299 - `#14483 <https://github.com/pytest-dev/pytest/issues/14483>`_: Fixed JUnit XML report incorrectly escaping high Unicode codepoints (supplementary plane characters like emoji) in test failure messages. -- by :user:`EternalRights`
300
301
302 - `#14492 <https://github.com/pytest-dev/pytest/issues/14492>`_: Fixed ``Code.getargs()`` incorrectly including local variable names in the returned argument tuple for functions with ``*args`` and/or ``**kwargs``. The method was using ``co_flags`` bitmask values (``4`` and ``8``) directly as counts instead of converting them to ``1`` via ``bool()``, and was not accounting for ``co_kwonlyargcount`` when ``var=True``.
303
304
305 - `#3697 <https://github.com/pytest-dev/pytest/issues/3697>`_: Logging capture now works for non-propagating loggers.
306 Previously only logs which reached the root logger were captured.
307 This includes :fixture:`caplog` and the "Captured log calls" test reporting.
308
309
310 - `#3850 <https://github.com/pytest-dev/pytest/issues/3850>`_: Fixed JUnit XML report: the ``tests`` attribute of the ``<testsuite>`` element now always matches the number of ``<testcase>`` elements in the file. In some cases (test passes but fails during teardown) the ``tests`` attribute would report an incorrect number of testcases in the XML file.
311
312
313 - `#5848 <https://github.com/pytest-dev/pytest/issues/5848>`_: :hook:`pytest_fixture_post_finalizer` is no longer called extra times for the same fixture teardown in some cases.
314
315
316 - `#719 <https://github.com/pytest-dev/pytest/issues/719>`_: Fixed :ref:`@pytest.mark.parametrize <pytest.mark.parametrize ref>` not unpacking single-element tuple values when using a string argnames with a trailing comma (e.g., ``"arg,"``).
317
318 The trailing comma form now correctly behaves like the tuple form ``("arg",)``, treating argvalues as a list of tuples to unpack.
319
320
321
322 Improved documentation
323 ----------------------
324
325 - `#11022 <https://github.com/pytest-dev/pytest/issues/11022>`_: Document safer alternatives and scope guidance for monkeypatching standard library functions.
326
327
328 - `#11307 <https://github.com/pytest-dev/pytest/issues/11307>`_: Document that ``@pytest.hookimpl(specname=...)`` only works for function names starting with ``pytest_``.
329
330
331 - `#13038 <https://github.com/pytest-dev/pytest/issues/13038>`_: Document that doctests do not support parametrized fixtures, including parametrized autouse fixtures.
332
333
334 - `#13155 <https://github.com/pytest-dev/pytest/issues/13155>`_: Clarified how the ``request`` fixture provides indirect parametrization values via ``request.param``.
335
336
337 - `#13304 <https://github.com/pytest-dev/pytest/issues/13304>`_: Clarified in the documentation that hook implementations defined in ``conftest.py`` files are not available to other plugins during their ``pytest_addoption()`` execution, as conftest files are discovered and loaded after builtin and third-party plugins have been initialized. However, initial conftest files themselves can implement ``pytest_addoption()`` to add their own command-line options.
338
339
340 - `#13902 <https://github.com/pytest-dev/pytest/issues/13902>`_: Clarified how subtest progress markers are shown in the documentation.
341
342
343 - `#14012 <https://github.com/pytest-dev/pytest/issues/14012>`_: The :ref:`ini options ref` section of the API Reference now specified the type and default value of every configuration option.
344
345
346 - `#14148 <https://github.com/pytest-dev/pytest/issues/14148>`_: Documented a safe ``pytestconfig.cache`` access pattern when the
347 ``cacheprovider`` plugin is disabled.
348
349
350 - `#14303 <https://github.com/pytest-dev/pytest/issues/14303>`_: The documentation is now built with Sphinx >= 9.
351
352
353 - `#14465 <https://github.com/pytest-dev/pytest/issues/14465>`_: Updated the hooks how-to page to link the ``newhooks.py`` file in ``pytest-xdist`` at tag ``v3.8.0`` instead of an unrelated 2017-era commit under the old layout. Pointing at a tag keeps the example in sync with the version users actually install, while remaining stable when the project's main branch moves on.
354
355
356
357 Miscellaneous internal changes
358 ------------------------------
359
360 - `#14582 <https://github.com/pytest-dev/pytest/issues/14582>`_: Improved the recursion traceback test to exercise all requested traceback styles.
361
362
363 pytest 9.0.3 (2026-04-07)
364 =========================
365
366 Bug fixes
367 ---------
368
369 - `#12444 <https://github.com/pytest-dev/pytest/issues/12444>`_: Fixed :func:`pytest.approx` which now correctly takes into account :class:`~collections.abc.Mapping` keys order to compare them.
370
371
372 - `#13634 <https://github.com/pytest-dev/pytest/issues/13634>`_: Blocking a ``conftest.py`` file using the ``-p no:`` option is now explicitly disallowed.
373
374 Previously this resulted in an internal assertion failure during plugin loading.
375
376 Pytest now raises a clear ``UsageError`` explaining that conftest files are not plugins and cannot be disabled via ``-p``.
377
378
379 - `#13734 <https://github.com/pytest-dev/pytest/issues/13734>`_: Fixed crash when a test raises an exceptiongroup with ``__tracebackhide__ = True``.
380
381
382 - `#14195 <https://github.com/pytest-dev/pytest/issues/14195>`_: Fixed an issue where non-string messages passed to `unittest.TestCase.subTest()` were not printed.
383
384
385 - `#14343 <https://github.com/pytest-dev/pytest/issues/14343>`_: Fixed use of insecure temporary directory (CVE-2025-71176).
386
387
388
389 Improved documentation
390 ----------------------
391
392 - `#13388 <https://github.com/pytest-dev/pytest/issues/13388>`_: Clarified documentation for ``-p`` vs ``PYTEST_PLUGINS`` plugin loading and fixed an incorrect ``-p`` example.
393
394
395 - `#13731 <https://github.com/pytest-dev/pytest/issues/13731>`_: Clarified that capture fixtures (e.g. ``capsys`` and ``capfd``) take precedence over the ``-s`` / ``--capture=no`` command-line options in :ref:`Accessing captured output from a test function <accessing-captured-output>`.
396
397
398 - `#14088 <https://github.com/pytest-dev/pytest/issues/14088>`_: Clarified that the default :hook:`pytest_collection` hook sets ``session.items`` before it calls :hook:`pytest_collection_finish`, not after.
399
400
401 - `#14255 <https://github.com/pytest-dev/pytest/issues/14255>`_: TOML integer log levels must be quoted: Updating reference documentation.
402
403
404
405 Contributor-facing changes
406 --------------------------
407
408 - `#12689 <https://github.com/pytest-dev/pytest/issues/12689>`_: The test reports are now published to Codecov from GitHub Actions.
409 The test statistics is visible `on the web interface
410 <https://app.codecov.io/gh/pytest-dev/pytest/tests>`__.
411
412 -- by :user:`aleguy02`
413
414
415 pytest 9.0.2 (2025-12-06)
416 =========================
417
418 Bug fixes
419 ---------
420
421 - `#13896 <https://github.com/pytest-dev/pytest/issues/13896>`_: The terminal progress feature added in pytest 9.0.0 has been disabled by default, except on Windows, due to compatibility issues with some terminal emulators.
422
423 You may enable it again by passing ``-p terminalprogress``. We may enable it by default again once compatibility improves in the future.
424
425 Additionally, when the environment variable ``TERM`` is ``dumb``, the escape codes are no longer emitted, even if the plugin is enabled.
426
427
428 - `#13904 <https://github.com/pytest-dev/pytest/issues/13904>`_: Fixed the TOML type of the :confval:`tmp_path_retention_count` settings in the API reference from number to string.
429
430
431 - `#13946 <https://github.com/pytest-dev/pytest/issues/13946>`_: The private ``config.inicfg`` attribute was changed in a breaking manner in pytest 9.0.0.
432 Due to its usage in the ecosystem, it is now restored to working order using a compatibility shim.
433 It will be deprecated in pytest 9.1 and removed in pytest 10.
434
435
436 - `#13965 <https://github.com/pytest-dev/pytest/issues/13965>`_: Fixed quadratic-time behavior when handling ``unittest`` subtests in Python 3.10.
437
438
439
440 Improved documentation
441 ----------------------
442
443 - `#4492 <https://github.com/pytest-dev/pytest/issues/4492>`_: The API Reference now contains cross-reference-able documentation of :ref:`pytest's command-line flags <command-line-flags>`.
444
445
446 pytest 9.0.1 (2025-11-12)
447 =========================
448
449 Bug fixes
450 ---------
451
452 - `#13895 <https://github.com/pytest-dev/pytest/issues/13895>`_: Restore support for skipping tests via ``raise unittest.SkipTest``.
453
454
455 - `#13896 <https://github.com/pytest-dev/pytest/issues/13896>`_: The terminal progress plugin added in pytest 9.0 is now automatically disabled when iTerm2 is detected, it generated desktop notifications instead of the desired functionality.
456
457
458 - `#13904 <https://github.com/pytest-dev/pytest/issues/13904>`_: Fixed the TOML type of the verbosity settings in the API reference from number to string.
459
460
461 - `#13910 <https://github.com/pytest-dev/pytest/issues/13910>`_: Fixed `UserWarning: Do not expect file_or_dir` on some earlier Python 3.12 and 3.13 point versions.
462
463
464
465 Packaging updates and notes for downstreams
466 -------------------------------------------
467
468 - `#13933 <https://github.com/pytest-dev/pytest/issues/13933>`_: The tox configuration has been adjusted to make sure the desired
469 version string can be passed into its :ref:`package_env` through
470 the ``SETUPTOOLS_SCM_PRETEND_VERSION_FOR_PYTEST`` environment
471 variable as a part of the release process -- by :user:`webknjaz`.
472
473
474
475 Contributor-facing changes
476 --------------------------
477
478 - `#13891 <https://github.com/pytest-dev/pytest/issues/13891>`_, `#13942 <https://github.com/pytest-dev/pytest/issues/13942>`_: The CI/CD part of the release automation is now capable of
479 creating GitHub Releases without having a Git checkout on
480 disk -- by :user:`bluetech` and :user:`webknjaz`.
481
482
483 - `#13933 <https://github.com/pytest-dev/pytest/issues/13933>`_: The tox configuration has been adjusted to make sure the desired
484 version string can be passed into its :ref:`package_env` through
485 the ``SETUPTOOLS_SCM_PRETEND_VERSION_FOR_PYTEST`` environment
486 variable as a part of the release process -- by :user:`webknjaz`.
487
488
489 pytest 9.0.0 (2025-11-05)
490 =========================
491
492 New features
493 ------------
494
495
496 - `#1367 <https://github.com/pytest-dev/pytest/issues/1367>`_: **Support for subtests** has been added.
497
498 :ref:`subtests <subtests>` are an alternative to parametrization, useful in situations where the parametrization values are not all known at collection time.
499
500 Example:
501
502 .. code-block:: python
503
504 def contains_docstring(p: Path) -> bool:
505 """Return True if the given Python file contains a top-level docstring."""
506 ...
507
508
509 def test_py_files_contain_docstring(subtests: pytest.Subtests) -> None:
510 for path in Path.cwd().glob("*.py"):
511 with subtests.test(path=str(path)):
512 assert contains_docstring(path)
513
514
515 Each assert failure or error is caught by the context manager and reported individually, giving a clear picture of all files that are missing a docstring.
516
517 In addition, :meth:`unittest.TestCase.subTest` is now also supported.
518
519 This feature was originally implemented as a separate plugin in `pytest-subtests <https://github.com/pytest-dev/pytest-subtests>`__, but since then has been merged into the core.
520
521 .. note::
522
523 This feature is experimental and will likely evolve in future releases. By that we mean that we might change how subtests are reported on failure, but the functionality and how to use it are stable.
524
525
526 - `#13743 <https://github.com/pytest-dev/pytest/issues/13743>`_: Added support for **native TOML configuration files**.
527
528 While pytest, since version 6, supports configuration in ``pyproject.toml`` files under ``[tool.pytest.ini_options]``,
529 it does so in an "INI compatibility mode", where all configuration values are treated as strings or list of strings.
530 Now, pytest supports the native TOML data model.
531
532 In ``pyproject.toml``, the native TOML configuration is under the ``[tool.pytest]`` table.
533
534 .. code-block:: toml
535
536 # pyproject.toml
537 [tool.pytest]
538 minversion = "9.0"
539 addopts = ["-ra", "-q"]
540 testpaths = [
541 "tests",
542 "integration",
543 ]
544
545 The ``[tool.pytest.ini_options]`` table remains supported, but both tables cannot be used at the same time.
546
547 If you prefer to use a separate configuration file, or don't use ``pyproject.toml``, you can use ``pytest.toml`` or ``.pytest.toml``:
548
549 .. code-block:: toml
550
551 # pytest.toml or .pytest.toml
552 [pytest]
553 minversion = "9.0"
554 addopts = ["-ra", "-q"]
555 testpaths = [
556 "tests",
557 "integration",
558 ]
559
560 The documentation now (sometimes) shows configuration snippets in both TOML and INI formats, in a tabbed interface.
561
562 See :ref:`config file formats` for full details.
563
564
565 - `#13823 <https://github.com/pytest-dev/pytest/issues/13823>`_: Added a **"strict mode"** enabled by the :confval:`strict` configuration option.
566
567 When set to ``true``, the :confval:`strict` option currently enables
568
569 * :confval:`strict_config`
570 * :confval:`strict_markers`
571 * :confval:`strict_parametrization_ids`
572 * :confval:`strict_xfail`
573
574 The individual strictness options can be explicitly set to override the global :confval:`strict` setting.
575
576 The previously-deprecated ``--strict`` command-line flag now enables strict mode.
577
578 If pytest adds new strictness options in the future, they will also be enabled in strict mode.
579 Therefore, you should only enable strict mode if you use a pinned/locked version of pytest,
580 or if you want to proactively adopt new strictness options as they are added.
581
582 See :ref:`strict mode` for more details.
583
584
585 - `#13737 <https://github.com/pytest-dev/pytest/issues/13737>`_: Added the :confval:`strict_parametrization_ids` configuration option.
586
587 When set, pytest emits an error if it detects non-unique parameter set IDs,
588 rather than automatically making the IDs unique by adding `0`, `1`, ... to them.
589 This can be particularly useful for catching unintended duplicates.
590
591
592 - `#13072 <https://github.com/pytest-dev/pytest/issues/13072>`_: Added support for displaying test session **progress in the terminal tab** using the `OSC 9;4; <https://conemu.github.io/en/AnsiEscapeCodes.html#ConEmu_specific_OSC>`_ ANSI sequence.
593
594 **Note**: *This feature has been disabled by default in version 9.0.2, except on Windows, due to compatibility issues with some terminal emulators.
595 You may enable it again by passing* ``-p terminalprogress``. *We may enable it by default again once compatibility improves in the future.*
596
597 When pytest runs in a supported terminal emulator like ConEmu, Gnome Terminal, Ptyxis, Windows Terminal, Kitty or Ghostty,
598 you'll see the progress in the terminal tab or window,
599 allowing you to monitor pytest's progress at a glance.
600
601 This feature is automatically enabled when running in a TTY. It is implemented as an internal plugin. If needed, it can be disabled as follows:
602 - On a user level, using ``-p no:terminalprogress`` on the command line or via an environment variable ``PYTEST_ADDOPTS='-p no:terminalprogress'``.
603 - On a project configuration level, using ``addopts = "-p no:terminalprogress"``.
604
605
606 - `#478 <https://github.com/pytest-dev/pytest/issues/478>`_: Support PEP420 (implicit namespace packages) as `--pyargs` target when :confval:`consider_namespace_packages` is `true` in the config.
607
608 Previously, this option only impacted package imports, now it also impacts tests discovery.
609
610
611 - `#13678 <https://github.com/pytest-dev/pytest/issues/13678>`_: Added a new :confval:`faulthandler_exit_on_timeout` configuration option set to "false" by default to let `faulthandler` interrupt the `pytest` process after a timeout in case of deadlock.
612
613 Previously, a `faulthandler` timeout would only dump the traceback of all threads to stderr, but would not interrupt the `pytest` process.
614
615 -- by :user:`ogrisel`.
616
617
618 - `#13829 <https://github.com/pytest-dev/pytest/issues/13829>`_: Added support for configuration option aliases via the ``aliases`` parameter in :meth:`Parser.addini() <pytest.Parser.addini>`.
619
620 Plugins can now register alternative names for configuration options,
621 allowing for more flexibility in configuration naming and supporting backward compatibility when renaming options.
622 The canonical name always takes precedence if both the canonical name and an alias are specified in the configuration file.
623
624
625
626 Improvements in existing functionality
627 --------------------------------------
628
629 - `#13330 <https://github.com/pytest-dev/pytest/issues/13330>`_: Having pytest configuration spread over more than one file (for example having both a ``pytest.ini`` file and ``pyproject.toml`` with a ``[tool.pytest.ini_options]`` table) will now print a warning to make it clearer to the user that only one of them is actually used.
630
631 -- by :user:`sgaist`
632
633
634 - `#13574 <https://github.com/pytest-dev/pytest/issues/13574>`_: The single argument ``--version`` no longer loads the entire plugin infrastructure, making it faster and more reliable when displaying only the pytest version.
635
636 Passing ``--version`` twice (e.g., ``pytest --version --version``) retains the original behavior, showing both the pytest version and plugin information.
637
638 .. note::
639
640 Since ``--version`` is now processed early, it only takes effect when passed directly via the command line. It will not work if set through other mechanisms, such as :envvar:`PYTEST_ADDOPTS` or :confval:`addopts`.
641
642
643 - `#13823 <https://github.com/pytest-dev/pytest/issues/13823>`_: Added :confval:`strict_xfail` as an alias to the ``xfail_strict`` option,
644 :confval:`strict_config` as an alias to the ``--strict-config`` flag,
645 and :confval:`strict_markers` as an alias to the ``--strict-markers`` flag.
646 This makes all strictness options consistently have configuration options with the prefix ``strict_``.
647
648 - `#13700 <https://github.com/pytest-dev/pytest/issues/13700>`_: `--junitxml` no longer prints the `generated xml file` summary at the end of the pytest session when `--quiet` is given.
649
650
651 - `#13732 <https://github.com/pytest-dev/pytest/issues/13732>`_: Previously, when filtering warnings, pytest would fail if the filter referenced a class that could not be imported. Now, this only outputs a message indicating the problem.
652
653
654 - `#13859 <https://github.com/pytest-dev/pytest/issues/13859>`_: Clarify the error message for `pytest.raises()` when a regex `match` fails.
655
656
657 - `#13861 <https://github.com/pytest-dev/pytest/issues/13861>`_: Better sentence structure in a test's expected error message. Previously, the error message would be "expected exception must be <expected>, but got <actual>". Now, it is "Expected <expected>, but got <actual>".
658
659
660 Removals and backward incompatible breaking changes
661 ---------------------------------------------------
662
663 - `#12083 <https://github.com/pytest-dev/pytest/issues/12083>`_: Fixed a bug where an invocation such as `pytest a/ a/b` would cause only tests from `a/b` to run, and not other tests under `a/`.
664
665 The fix entails a few breaking changes to how such overlapping arguments and duplicates are handled:
666
667 1. `pytest a/b a/` or `pytest a/ a/b` are equivalent to `pytest a`; if an argument overlaps another arguments, only the prefix remains.
668
669 2. `pytest x.py x.py` is equivalent to `pytest x.py`; previously such an invocation was taken as an explicit request to run the tests from the file twice.
670
671 If you rely on these behaviors, consider using :ref:`--keep-duplicates <duplicate-paths>`, which retains its existing behavior (including the bug).
672
673
674 - `#13719 <https://github.com/pytest-dev/pytest/issues/13719>`_: Support for Python 3.9 is dropped following its end of life.
675
676
677 - `#13766 <https://github.com/pytest-dev/pytest/issues/13766>`_: Previously, pytest would assume it was running in a CI/CD environment if either of the environment variables `$CI` or `$BUILD_NUMBER` was defined;
678 now, CI mode is only activated if at least one of those variables is defined and set to a *non-empty* value.
679
680
681 - The non-public ``config.args`` attribute used to be able to contain ``pathlib.Path`` instances; now it can only contain strings.
682
683
684 - `#13779 <https://github.com/pytest-dev/pytest/issues/13779>`_: **PytestRemovedIn9Warning deprecation warnings are now errors by default.**
685
686 Following our plan to remove deprecated features with as little disruption as
687 possible, all warnings of type ``PytestRemovedIn9Warning`` now generate errors
688 instead of warning messages by default.
689
690 **The affected features will be effectively removed in pytest 9.1**, so please consult the
691 :ref:`deprecations` section in the docs for directions on how to update existing code.
692
693 In the pytest ``9.0.X`` series, it is possible to change the errors back into warnings as a
694 stopgap measure by adding this to your ``pytest.ini`` file:
695
696 .. code-block:: ini
697
698 [pytest]
699 filterwarnings =
700 ignore::pytest.PytestRemovedIn9Warning
701
702 But this will stop working when pytest ``9.1`` is released.
703
704 **If you have concerns** about the removal of a specific feature, please add a
705 comment to :issue:`13779`.
706
707
708
709 Deprecations (removal in next major release)
710 --------------------------------------------
711
712 - `#13807 <https://github.com/pytest-dev/pytest/issues/13807>`_: :meth:`monkeypatch.syspath_prepend() <pytest.MonkeyPatch.syspath_prepend>` now issues a deprecation warning when the prepended path contains legacy namespace packages (those using ``pkg_resources.declare_namespace()``).
713 Users should migrate to native namespace packages (:pep:`420`).
714 See :ref:`monkeypatch-fixup-namespace-packages` for details.
715
716
717 Bug fixes
718 ---------
719
720 - `#13445 <https://github.com/pytest-dev/pytest/issues/13445>`_: Made the type annotations of :func:`pytest.skip` and friends more spec-complaint to have them work across more type checkers.
721
722
723 - `#13537 <https://github.com/pytest-dev/pytest/issues/13537>`_: Fixed a bug in which :class:`ExceptionGroup` with only ``Skipped`` exceptions in teardown was not handled correctly and showed as error.
724
725
726 - `#13598 <https://github.com/pytest-dev/pytest/issues/13598>`_: Fixed possible collection confusion on Windows when short paths and symlinks are involved.
727
728
729 - `#13716 <https://github.com/pytest-dev/pytest/issues/13716>`_: Fixed a bug where a nonsensical invocation like ``pytest x.py[a]`` (a file cannot be parametrized) was silently treated as ``pytest x.py``. This is now a usage error.
730
731
732 - `#13722 <https://github.com/pytest-dev/pytest/issues/13722>`_: Fixed a misleading assertion failure message when using :func:`pytest.approx` on mappings with differing lengths.
733
734
735 - `#13773 <https://github.com/pytest-dev/pytest/issues/13773>`_: Fixed the static fixture closure calculation to properly consider transitive dependencies requested by overridden fixtures.
736
737
738 - `#13816 <https://github.com/pytest-dev/pytest/issues/13816>`_: Fixed :func:`pytest.approx` which now returns a clearer error message when comparing mappings with different keys.
739
740
741 - `#13849 <https://github.com/pytest-dev/pytest/issues/13849>`_: Hidden ``.pytest.ini`` files are now picked up as the config file even if empty.
742 This was an inconsistency with non-hidden ``pytest.ini``.
743
744
745 - `#13865 <https://github.com/pytest-dev/pytest/issues/13865>`_: Fixed `--show-capture` with `--tb=line`.
746
747
748 - `#13522 <https://github.com/pytest-dev/pytest/issues/13522>`_: Fixed :fixture:`pytester` in subprocess mode ignored all :attr:`pytester.plugins <pytest.Pytester.plugins>` except the first.
749
750 Fixed :fixture:`pytester` in subprocess mode silently ignored non-str :attr:`pytester.plugins <pytest.Pytester.plugins>`.
751 Now it errors instead.
752 If you are affected by this, specify the plugin by name, or switch the affected tests to use :func:`pytester.runpytest_inprocess <pytest.Pytester.runpytest_inprocess>` explicitly instead.
753
754
755
756 Packaging updates and notes for downstreams
757 -------------------------------------------
758
759 - `#13791 <https://github.com/pytest-dev/pytest/issues/13791>`_: Minimum requirements on ``iniconfig`` and ``packaging`` were bumped to ``1.0.1`` and ``22.0.0``, respectively.
760
761
762
763 Contributor-facing changes
764 --------------------------
765
766 - `#12244 <https://github.com/pytest-dev/pytest/issues/12244>`_: Fixed self-test failures when `TERM=dumb`.
767
768
769 - `#12474 <https://github.com/pytest-dev/pytest/issues/12474>`_: Added scheduled GitHub Action Workflow to run Sphinx linkchecks in repo documentation.
770
771
772 - `#13621 <https://github.com/pytest-dev/pytest/issues/13621>`_: pytest's own testsuite now handles the ``lsof`` command hanging (e.g. due to unreachable network filesystems), with the affected selftests being skipped after 10 seconds.
773
774
775 - `#13638 <https://github.com/pytest-dev/pytest/issues/13638>`_: Fixed deprecated :command:`gh pr new` command in :file:`scripts/prepare-release-pr.py`.
776 The script now uses :command:`gh pr create` which is compatible with GitHub CLI v2.0+.
777
778
779 - `#13695 <https://github.com/pytest-dev/pytest/issues/13695>`_: Flush `stdout` and `stderr` in `Pytester.run` to avoid truncated outputs in `test_faulthandler.py::test_timeout` on CI -- by :user:`ogrisel`.
780
781
782 - `#13771 <https://github.com/pytest-dev/pytest/issues/13771>`_: Skip `test_do_not_collect_symlink_siblings` on Windows environments without symlink support to avoid false negatives.
783
784
785 - `#13841 <https://github.com/pytest-dev/pytest/issues/13841>`_: ``tox>=4`` is now required when contributing to pytest.
786
787 - `#13625 <https://github.com/pytest-dev/pytest/issues/13625>`_: Added missing docstrings to ``pytest_addoption()``, ``pytest_configure()``, and ``cacheshow()`` functions in ``cacheprovider.py``.
788
789
790
791 Miscellaneous internal changes
792 ------------------------------
793
794 - `#13830 <https://github.com/pytest-dev/pytest/issues/13830>`_: Configuration overrides (``-o``/``--override-ini``) are now processed during startup rather than during :func:`config.getini() <pytest.Config.getini>`.
795
796
797 pytest 8.4.2 (2025-09-03)
798 =========================
799
800 Bug fixes
801 ---------
802
803 - `#13478 <https://github.com/pytest-dev/pytest/issues/13478>`_: Fixed a crash when using :confval:`console_output_style` with ``times`` and a module is skipped.
804
805
806 - `#13530 <https://github.com/pytest-dev/pytest/issues/13530>`_: Fixed a crash when using :func:`pytest.approx` and :class:`decimal.Decimal` instances with the :class:`decimal.FloatOperation` trap set.
807
808
809 - `#13549 <https://github.com/pytest-dev/pytest/issues/13549>`_: No longer evaluate type annotations in Python ``3.14`` when inspecting function signatures.
810
811 This prevents crashes during module collection when modules do not explicitly use ``from __future__ import annotations`` and import types for annotations within a ``if TYPE_CHECKING:`` block.
812
813
814 - `#13559 <https://github.com/pytest-dev/pytest/issues/13559>`_: Added missing `int` and `float` variants to the `Literal` type annotation of the `type` parameter in :meth:`pytest.Parser.addini`.
815
816
817 - `#13563 <https://github.com/pytest-dev/pytest/issues/13563>`_: :func:`pytest.approx` now only imports ``numpy`` if NumPy is already in ``sys.modules``. This fixes unconditional import behavior introduced in `8.4.0`.
818
819
820
821 Improved documentation
822 ----------------------
823
824 - `#13577 <https://github.com/pytest-dev/pytest/issues/13577>`_: Clarify that ``pytest_generate_tests`` is discovered in test modules/classes; other hooks must be in ``conftest.py`` or plugins.
825
826
827
828 Contributor-facing changes
829 --------------------------
830
831 - `#13480 <https://github.com/pytest-dev/pytest/issues/13480>`_: Self-testing: fixed a few test failures when run with ``-Wdefault`` or a similar override.
832
833
834 - `#13547 <https://github.com/pytest-dev/pytest/issues/13547>`_: Self-testing: corrected expected message for ``test_doctest_unexpected_exception`` in Python ``3.14``.
835
836
837 - `#13684 <https://github.com/pytest-dev/pytest/issues/13684>`_: Make pytest's own testsuite insensitive to the presence of the ``CI`` environment variable -- by :user:`ogrisel`.
838
839
840 pytest 8.4.1 (2025-06-17)
841 =========================
842
843 Bug fixes
844 ---------
845
846 - `#13461 <https://github.com/pytest-dev/pytest/issues/13461>`_: Corrected ``_pytest.terminal.TerminalReporter.isatty`` to support
847 being called as a method. Before it was just a boolean which could
848 break correct code when using ``-o log_cli=true``).
849
850
851 - `#13477 <https://github.com/pytest-dev/pytest/issues/13477>`_: Reintroduced :class:`pytest.PytestReturnNotNoneWarning` which was removed by accident in pytest `8.4`.
852
853 This warning is raised when a test functions returns a value other than ``None``, which is often a mistake made by beginners.
854
855 See :ref:`return-not-none` for more information.
856
857
858 - `#13497 <https://github.com/pytest-dev/pytest/issues/13497>`_: Fixed compatibility with ``Twisted 25+``.
859
860
861
862 Improved documentation
863 ----------------------
864
865 - `#13492 <https://github.com/pytest-dev/pytest/issues/13492>`_: Fixed outdated warning about ``faulthandler`` not working on Windows.
866
867
868 pytest 8.4.0 (2025-06-02)
869 =========================
870
871 Removals and backward incompatible breaking changes
872 ---------------------------------------------------
873
874 - `#11372 <https://github.com/pytest-dev/pytest/issues/11372>`_: Async tests will now fail, instead of warning+skipping, if you don't have any suitable plugin installed.
875
876
877 - `#12346 <https://github.com/pytest-dev/pytest/issues/12346>`_: Tests will now fail, instead of raising a warning, if they return any value other than None.
878
879
880 - `#12874 <https://github.com/pytest-dev/pytest/issues/12874>`_: We dropped support for Python 3.8 following its end of life (2024-10-07).
881
882
883 - `#12960 <https://github.com/pytest-dev/pytest/issues/12960>`_: Test functions containing a yield now cause an explicit error. They have not been run since pytest 4.0, and were previously marked as an expected failure and deprecation warning.
884
885 See :ref:`the docs <yield tests deprecated>` for more information.
886
887
888
889 Deprecations (removal in next major release)
890 --------------------------------------------
891
892 - `#10839 <https://github.com/pytest-dev/pytest/issues/10839>`_: Requesting an asynchronous fixture without a `pytest_fixture_setup` hook that resolves it will now give a DeprecationWarning. This most commonly happens if a sync test requests an async fixture. This should have no effect on a majority of users with async tests or fixtures using async pytest plugins, but may affect non-standard hook setups or ``autouse=True``. For guidance on how to work around this warning see :ref:`sync-test-async-fixture`.
893
894
895
896 New features
897 ------------
898
899 - `#11538 <https://github.com/pytest-dev/pytest/issues/11538>`_: Added :class:`pytest.RaisesGroup` as an equivalent to :func:`pytest.raises` for expecting :exc:`ExceptionGroup`. Also adds :class:`pytest.RaisesExc` which is now the logic behind :func:`pytest.raises` and used as parameter to :class:`pytest.RaisesGroup`. ``RaisesGroup`` includes the ability to specify multiple different expected exceptions, the structure of nested exception groups, and flags for emulating :ref:`except* <except_star>`. See :ref:`assert-matching-exception-groups` and docstrings for more information.
900
901
902 - `#12081 <https://github.com/pytest-dev/pytest/issues/12081>`_: Added :fixture:`capteesys` to capture AND pass output to next handler set by ``--capture=``.
903
904
905 - `#12504 <https://github.com/pytest-dev/pytest/issues/12504>`_: :func:`pytest.mark.xfail` now accepts :class:`pytest.RaisesGroup` for the ``raises`` parameter when you expect an exception group. You can also pass a :class:`pytest.RaisesExc` if you e.g. want to make use of the ``check`` parameter.
906
907
908 - `#12713 <https://github.com/pytest-dev/pytest/issues/12713>`_: New `--force-short-summary` option to force condensed summary output regardless of verbosity level.
909
910 This lets users still see condensed summary output of failures for quick reference in log files from job outputs, being especially useful if non-condensed output is very verbose.
911
912
913 - `#12749 <https://github.com/pytest-dev/pytest/issues/12749>`_: pytest traditionally collects classes/functions in the test module namespace even if they are imported from another file.
914
915 For example:
916
917 .. code-block:: python
918
919 # contents of src/domain.py
920 class Testament: ...
921
922
923 # contents of tests/test_testament.py
924 from domain import Testament
925
926
927 def test_testament(): ...
928
929 In this scenario with the default options, pytest will collect the class `Testament` from `tests/test_testament.py` because it starts with `Test`, even though in this case it is a production class being imported in the test module namespace.
930
931 This behavior can now be prevented by setting the new :confval:`collect_imported_tests` configuration option to ``false``, which will make pytest collect classes/functions from test files **only** if they are defined in that file.
932
933 -- by :user:`FreerGit`
934
935
936 - `#12765 <https://github.com/pytest-dev/pytest/issues/12765>`_: Thresholds to trigger snippet truncation can now be set with :confval:`truncation_limit_lines` and :confval:`truncation_limit_chars`.
937
938 See :ref:`truncation-params` for more information.
939
940
941 - `#13125 <https://github.com/pytest-dev/pytest/issues/13125>`_: :confval:`console_output_style` now supports ``times`` to show execution time of each test.
942
943
944 - `#13192 <https://github.com/pytest-dev/pytest/issues/13192>`_: :func:`pytest.raises` will now raise a warning when passing an empty string to ``match``, as this will match against any value. Use ``match="^$"`` if you want to check that an exception has no message.
945
946
947 - `#13192 <https://github.com/pytest-dev/pytest/issues/13192>`_: :func:`pytest.raises` will now print a helpful string diff if matching fails and the match parameter has ``^`` and ``$`` and is otherwise escaped.
948
949
950 - `#13192 <https://github.com/pytest-dev/pytest/issues/13192>`_: You can now pass :func:`with pytest.raises(check=fn): <pytest.raises>`, where ``fn`` is a function which takes a raised exception and returns a boolean. The ``raises`` fails if no exception was raised (as usual), passes if an exception is raised and ``fn`` returns ``True`` (as well as ``match`` and the type matching, if specified, which are checked before), and propagates the exception if ``fn`` returns ``False`` (which likely also fails the test).
951
952
953 - `#13228 <https://github.com/pytest-dev/pytest/issues/13228>`_: :ref:`hidden-param` can now be used in ``id`` of :func:`pytest.param` or in
954 ``ids`` of :py:func:`Metafunc.parametrize <pytest.Metafunc.parametrize>`.
955 It hides the parameter set from the test name.
956
957
958 - `#13253 <https://github.com/pytest-dev/pytest/issues/13253>`_: New flag: :ref:`--disable-plugin-autoload <disable_plugin_autoload>` which works as an alternative to :envvar:`PYTEST_DISABLE_PLUGIN_AUTOLOAD` when setting environment variables is inconvenient; and allows setting it in config files with :confval:`addopts`.
959
960
961
962 Improvements in existing functionality
963 --------------------------------------
964
965 - `#10224 <https://github.com/pytest-dev/pytest/issues/10224>`_: pytest's ``short`` and ``long`` traceback styles (:ref:`how-to-modifying-python-tb-printing`)
966 now have partial :pep:`657` support and will show specific code segments in the
967 traceback.
968
969 .. code-block:: pytest
970
971 ================================= FAILURES =================================
972 _______________________ test_gets_correct_tracebacks _______________________
973
974 test_tracebacks.py:12: in test_gets_correct_tracebacks
975 assert manhattan_distance(p1, p2) == 1
976 ^^^^^^^^^^^^^^^^^^^^^^^^^^
977 test_tracebacks.py:6: in manhattan_distance
978 return abs(point_1.x - point_2.x) + abs(point_1.y - point_2.y)
979 ^^^^^^^^^
980 E AttributeError: 'NoneType' object has no attribute 'x'
981
982 -- by :user:`ammaraskar`
983
984
985 - `#11118 <https://github.com/pytest-dev/pytest/issues/11118>`_: Now :confval:`pythonpath` configures `$PYTHONPATH` earlier than before during the initialization process, which now also affects plugins loaded via the `-p` command-line option.
986
987 -- by :user:`millerdev`
988
989
990 - `#11381 <https://github.com/pytest-dev/pytest/issues/11381>`_: The ``type`` parameter of the ``parser.addini`` method now accepts `"int"` and ``"float"`` parameters, facilitating the parsing of configuration values in the configuration file.
991
992 Example:
993
994 .. code-block:: python
995
996 def pytest_addoption(parser):
997 parser.addini("int_value", type="int", default=2, help="my int value")
998 parser.addini("float_value", type="float", default=4.2, help="my float value")
999
1000 The `pytest.ini` file:
1001
1002 .. code-block:: ini
1003
1004 [pytest]
1005 int_value = 3
1006 float_value = 5.4
1007
1008
1009 - `#11525 <https://github.com/pytest-dev/pytest/issues/11525>`_: Fixtures are now clearly represented in the output as a "fixture object", not as a normal function as before, making it easy for beginners to catch mistakes such as referencing a fixture declared in the same module but not requested in the test function.
1010
1011 -- by :user:`the-compiler` and :user:`glyphack`
1012
1013
1014 - `#12426 <https://github.com/pytest-dev/pytest/issues/12426>`_: A warning is now issued when :ref:`pytest.mark.usefixtures ref` is used without specifying any fixtures. Previously, empty usefixtures markers were silently ignored.
1015
1016
1017 - `#12707 <https://github.com/pytest-dev/pytest/issues/12707>`_: Exception chains can be navigated when dropped into Pdb in Python 3.13+.
1018
1019
1020 - `#12736 <https://github.com/pytest-dev/pytest/issues/12736>`_: Added a new attribute `name` with the fixed value `"pytest tests"` to the root tag `testsuites` of the junit-xml generated by pytest.
1021
1022 This attribute is part of many junit-xml specifications and is even part of the `junit-10.xsd` specification that pytest's implementation is based on.
1023
1024
1025 - `#12943 <https://github.com/pytest-dev/pytest/issues/12943>`_: If a test fails with an exceptiongroup with a single exception, the contained exception will now be displayed in the short test summary info.
1026
1027
1028 - `#12958 <https://github.com/pytest-dev/pytest/issues/12958>`_: A number of :ref:`unraisable <unraisable>` enhancements:
1029
1030 * Set the unraisable hook as early as possible and unset it as late as possible, to collect the most possible number of unraisable exceptions.
1031 * Call the garbage collector just before unsetting the unraisable hook, to collect any straggling exceptions.
1032 * Collect multiple unraisable exceptions per test phase.
1033 * Report the :mod:`tracemalloc` allocation traceback (if available).
1034 * Avoid using a generator based hook to allow handling :class:`StopIteration` in test failures.
1035 * Report the unraisable exception as the cause of the :class:`pytest.PytestUnraisableExceptionWarning` exception if raised.
1036 * Compute the ``repr`` of the unraisable object in the unraisable hook so you get the latest information if available, and should help with resurrection of the object.
1037
1038
1039 - `#13010 <https://github.com/pytest-dev/pytest/issues/13010>`_: :func:`pytest.approx` now can compare collections that contain numbers and non-numbers mixed.
1040
1041
1042 - `#13016 <https://github.com/pytest-dev/pytest/issues/13016>`_: A number of :ref:`threadexception <unraisable>` enhancements:
1043
1044 * Set the excepthook as early as possible and unset it as late as possible, to collect the most possible number of unhandled exceptions from threads.
1045 * Collect multiple thread exceptions per test phase.
1046 * Report the :mod:`tracemalloc` allocation traceback (if available).
1047 * Avoid using a generator based hook to allow handling :class:`StopIteration` in test failures.
1048 * Report the thread exception as the cause of the :class:`pytest.PytestUnhandledThreadExceptionWarning` exception if raised.
1049 * Extract the ``name`` of the thread object in the excepthook which should help with resurrection of the thread.
1050
1051
1052 - `#13031 <https://github.com/pytest-dev/pytest/issues/13031>`_: An empty parameter set as in ``pytest.mark.parametrize([], ids=idfunc)`` will no longer trigger a call to ``idfunc`` with internal objects.
1053
1054
1055 - `#13115 <https://github.com/pytest-dev/pytest/issues/13115>`_: Allows supplying ``ExceptionGroup[Exception]`` and ``BaseExceptionGroup[BaseException]`` to ``pytest.raises`` to keep full typing on :class:`ExceptionInfo <pytest.ExceptionInfo>`:
1056
1057 .. code-block:: python
1058
1059 with pytest.raises(ExceptionGroup[Exception]) as exc_info:
1060 some_function()
1061
1062 Parametrizing with other exception types remains an error - we do not check the types of child exceptions and thus do not permit code that might look like we do.
1063
1064
1065 - `#13122 <https://github.com/pytest-dev/pytest/issues/13122>`_: The ``--stepwise`` mode received a number of improvements:
1066
1067 * It no longer forgets the last failed test in case pytest is executed later without the flag.
1068
1069 This enables the following workflow:
1070
1071 1. Execute pytest with ``--stepwise``, pytest then stops at the first failing test;
1072 2. Iteratively update the code and run the test in isolation, without the ``--stepwise`` flag (for example in an IDE), until it is fixed.
1073 3. Execute pytest with ``--stepwise`` again and pytest will continue from the previously failed test, and if it passes, continue on to the next tests.
1074
1075 Previously, at step 3, pytest would start from the beginning, forgetting the previously failed test.
1076
1077 This change however might cause issues if the ``--stepwise`` mode is used far apart in time, as the state might get stale, so the internal state will be reset automatically in case the test suite changes (for now only the number of tests are considered for this, we might change/improve this on the future).
1078
1079 * New ``--stepwise-reset``/``--sw-reset`` flag, allowing the user to explicitly reset the stepwise state and restart the workflow from the beginning.
1080
1081
1082 - `#13308 <https://github.com/pytest-dev/pytest/issues/13308>`_: Added official support for Python 3.14.
1083
1084
1085 - `#13380 <https://github.com/pytest-dev/pytest/issues/13380>`_: Fix :class:`ExceptionGroup` traceback filtering to exclude pytest internals.
1086
1087
1088 - `#13415 <https://github.com/pytest-dev/pytest/issues/13415>`_: The author metadata of the BibTex example is now correctly formatted with last names following first names.
1089 An example of BibLaTex has been added.
1090 BibTex and BibLaTex examples now clearly indicate that what is cited is software.
1091
1092 -- by :user:`willynilly`
1093
1094
1095 - `#13420 <https://github.com/pytest-dev/pytest/issues/13420>`_: Improved test collection performance by optimizing path resolution used in ``FSCollector``.
1096
1097
1098 - `#13457 <https://github.com/pytest-dev/pytest/issues/13457>`_: The error message about duplicate parametrization no longer displays an internal stack trace.
1099
1100
1101 - `#4112 <https://github.com/pytest-dev/pytest/issues/4112>`_: Using :ref:`pytest.mark.usefixtures <pytest.mark.usefixtures ref>` on :func:`pytest.param` now produces an error instead of silently doing nothing.
1102
1103
1104 - `#5473 <https://github.com/pytest-dev/pytest/issues/5473>`_: Replace `:` with `;` in the assertion rewrite warning message so it can be filtered using standard Python warning filters before calling :func:`pytest.main`.
1105
1106
1107 - `#6985 <https://github.com/pytest-dev/pytest/issues/6985>`_: Improved :func:`pytest.approx` to enhance the readability of value ranges and tolerances between 0.001 and 1000.
1108 * The `repr` method now provides clearer output for values within those ranges, making it easier to interpret the results.
1109 * Previously, the output for those ranges of values and tolerances was displayed in scientific notation (e.g., `42 ± 1.0e+00`). The updated method now presents the tolerance as a decimal for better readability (e.g., `42 ± 1`).
1110
1111 Example:
1112
1113 **Previous Output:**
1114
1115 .. code-block:: console
1116
1117 >>> pytest.approx(42, abs=1)
1118 42 ± 1.0e+00
1119
1120 **Current Output:**
1121
1122 .. code-block:: console
1123
1124 >>> pytest.approx(42, abs=1)
1125 42 ± 1
1126
1127 -- by :user:`fazeelghafoor`
1128
1129
1130 - `#7683 <https://github.com/pytest-dev/pytest/issues/7683>`_: The formerly optional ``pygments`` dependency is now required, causing output always to be source-highlighted (unless disabled via the ``--code-highlight=no`` CLI option).
1131
1132
1133
1134 Bug fixes
1135 ---------
1136
1137 - `#10404 <https://github.com/pytest-dev/pytest/issues/10404>`_: Apply filterwarnings from config/cli as soon as possible, and revert them as late as possible
1138 so that warnings as errors are collected throughout the pytest run and before the
1139 unraisable and threadexcept hooks are removed.
1140
1141 This allows very late warnings and unraisable/threadexcept exceptions to fail the test suite.
1142
1143 This also changes the warning that the lsof plugin issues from PytestWarning to the new warning PytestFDWarning so it can be more easily filtered.
1144
1145
1146 - `#11067 <https://github.com/pytest-dev/pytest/issues/11067>`_: The test report is now consistent regardless if the test xfailed via :ref:`pytest.mark.xfail <pytest.mark.xfail ref>` or :func:`pytest.fail`.
1147
1148 Previously, *xfailed* tests via the marker would have the string ``"reason: "`` prefixed to the message, while those *xfailed* via the function did not. The prefix has been removed.
1149
1150
1151 - `#12008 <https://github.com/pytest-dev/pytest/issues/12008>`_: In :pr:`11220`, an unintended change in reordering was introduced by changing the way indices were assigned to direct params. More specifically, before that change, the indices of direct params to metafunc's callspecs were assigned after all parametrizations took place. Now, that change is reverted.
1152
1153
1154 - `#12863 <https://github.com/pytest-dev/pytest/issues/12863>`_: Fix applying markers, including :ref:`pytest.mark.parametrize <pytest.mark.parametrize ref>` when placed above `@staticmethod` or `@classmethod`.
1155
1156
1157 - `#12929 <https://github.com/pytest-dev/pytest/issues/12929>`_: Handle StopIteration from test cases, setup and teardown correctly.
1158
1159
1160 - `#12938 <https://github.com/pytest-dev/pytest/issues/12938>`_: Fixed ``--durations-min`` argument not respected if ``-vv`` is used.
1161
1162
1163 - `#12946 <https://github.com/pytest-dev/pytest/issues/12946>`_: Fixed missing help for :mod:`pdb` commands wrapped by pytest -- by :user:`adamchainz`.
1164
1165
1166 - `#12981 <https://github.com/pytest-dev/pytest/issues/12981>`_: Prevent exceptions in :func:`pytest.Config.add_cleanup` callbacks preventing further cleanups.
1167
1168
1169 - `#13047 <https://github.com/pytest-dev/pytest/issues/13047>`_: Restore :func:`pytest.approx` handling of equality checks between `bool` and `numpy.bool_` types.
1170
1171 Comparing `bool` and `numpy.bool_` using :func:`pytest.approx` accidentally changed in version `8.3.4` and `8.3.5` to no longer match:
1172
1173 .. code-block:: pycon
1174
1175 >>> import numpy as np
1176 >>> from pytest import approx
1177 >>> [np.True_, np.True_] == pytest.approx([True, True])
1178 False
1179
1180 This has now been fixed:
1181
1182 .. code-block:: pycon
1183
1184 >>> [np.True_, np.True_] == pytest.approx([True, True])
1185 True
1186
1187
1188 - `#13119 <https://github.com/pytest-dev/pytest/issues/13119>`_: Improved handling of invalid regex patterns for filter warnings by providing a clear error message.
1189
1190
1191 - `#13175 <https://github.com/pytest-dev/pytest/issues/13175>`_: The diff is now also highlighted correctly when comparing two strings.
1192
1193
1194 - `#13248 <https://github.com/pytest-dev/pytest/issues/13248>`_: Fixed an issue where passing a ``scope`` in :py:func:`Metafunc.parametrize <pytest.Metafunc.parametrize>` with ``indirect=True``
1195 could result in other fixtures being unable to depend on the parametrized fixture.
1196
1197
1198 - `#13291 <https://github.com/pytest-dev/pytest/issues/13291>`_: Fixed ``repr`` of ``attrs`` objects in assertion failure messages when using ``attrs>=25.2``.
1199
1200
1201 - `#13312 <https://github.com/pytest-dev/pytest/issues/13312>`_: Fixed a possible ``KeyError`` crash on PyPy during collection of tests involving higher-scoped parameters.
1202
1203
1204 - `#13345 <https://github.com/pytest-dev/pytest/issues/13345>`_: Fix type hints for :attr:`pytest.TestReport.when` and :attr:`pytest.TestReport.location`.
1205
1206
1207 - `#13377 <https://github.com/pytest-dev/pytest/issues/13377>`_: Fixed handling of test methods with positional-only parameter syntax.
1208
1209 Now, methods are supported that formally define ``self`` as positional-only
1210 and/or fixture parameters as keyword-only, e.g.:
1211
1212 .. code-block:: python
1213
1214 class TestClass:
1215
1216 def test_method(self, /, *, fixture): ...
1217
1218 Before, this caused an internal error in pytest.
1219
1220
1221 - `#13384 <https://github.com/pytest-dev/pytest/issues/13384>`_: Fixed an issue where pytest could report negative durations.
1222
1223
1224 - `#13420 <https://github.com/pytest-dev/pytest/issues/13420>`_: Added ``lru_cache`` to ``nodes._check_initialpaths_for_relpath``.
1225
1226
1227 - `#9037 <https://github.com/pytest-dev/pytest/issues/9037>`_: Honor :confval:`disable_test_id_escaping_and_forfeit_all_rights_to_community_support` when escaping ids in parametrized tests.
1228
1229
1230
1231 Improved documentation
1232 ----------------------
1233
1234 - `#12535 <https://github.com/pytest-dev/pytest/issues/12535>`_: `This
1235 example`<https://docs.pytest.org/en/latest/example/simple.html#making-test-result-information-available-in-fixtures>
1236 showed ``print`` statements that do not exactly reflect what the
1237 different branches actually do. The fix makes the example more precise.
1238
1239
1240 - `#13218 <https://github.com/pytest-dev/pytest/issues/13218>`_: Pointed out in the :func:`pytest.approx` documentation that it considers booleans unequal to numeric zero or one.
1241
1242
1243 - `#13221 <https://github.com/pytest-dev/pytest/issues/13221>`_: Improved grouping of CLI options in the ``--help`` output.
1244
1245
1246 - `#6649 <https://github.com/pytest-dev/pytest/issues/6649>`_: Added :class:`~pytest.TerminalReporter` to the :ref:`api-reference` documentation page.
1247
1248
1249 - `#8612 <https://github.com/pytest-dev/pytest/issues/8612>`_: Add a recipe for handling abstract test classes in the documentation.
1250
1251 A new example has been added to the documentation to demonstrate how to use a mixin class to handle abstract
1252 test classes without manually setting the ``__test__`` attribute for subclasses.
1253 This ensures that subclasses of abstract test classes are automatically collected by pytest.
1254
1255
1256
1257 Packaging updates and notes for downstreams
1258 -------------------------------------------
1259
1260 - `#13317 <https://github.com/pytest-dev/pytest/issues/13317>`_: Specified minimum allowed versions of ``colorama``, ``iniconfig``,
1261 and ``packaging``; and bumped the minimum allowed version
1262 of ``exceptiongroup`` for ``python_version<'3.11'`` from a release
1263 candidate to a full release.
1264
1265
1266
1267 Contributor-facing changes
1268 --------------------------
1269
1270 - `#12017 <https://github.com/pytest-dev/pytest/issues/12017>`_: Mixed internal improvements:
1271
1272 * Migrate formatting to f-strings in some tests.
1273 * Use type-safe constructs in JUnitXML tests.
1274 * Moved`` MockTiming`` into ``_pytest.timing``.
1275
1276 -- by :user:`RonnyPfannschmidt`
1277
1278
1279 - `#12647 <https://github.com/pytest-dev/pytest/issues/12647>`_: Fixed running the test suite with the ``hypothesis`` pytest plugin.
1280
1281
1282
1283 Miscellaneous internal changes
1284 ------------------------------
1285
1286 - `#6649 <https://github.com/pytest-dev/pytest/issues/6649>`_: Added :class:`~pytest.TerminalReporter` to the public pytest API, as it is part of the signature of the :hook:`pytest_terminal_summary` hook.
1287
1288
1289 pytest 8.3.5 (2025-03-02)
1290 =========================
1291
1292 Bug fixes
1293 ---------
1294
1295 - `#11777 <https://github.com/pytest-dev/pytest/issues/11777>`_: Fixed issue where sequences were still being shortened even with ``-vv`` verbosity.
1296
1297
1298 - `#12888 <https://github.com/pytest-dev/pytest/issues/12888>`_: Fixed broken input when using Python 3.13+ and a ``libedit`` build of Python, such as on macOS or with uv-managed Python binaries from the ``python-build-standalone`` project. This could manifest e.g. by a broken prompt when using ``Pdb``, or seeing empty inputs with manual usage of ``input()`` and suspended capturing.
1299
1300
1301 - `#13026 <https://github.com/pytest-dev/pytest/issues/13026>`_: Fixed :class:`AttributeError` crash when using ``--import-mode=importlib`` when top-level directory same name as another module of the standard library.
1302
1303
1304 - `#13053 <https://github.com/pytest-dev/pytest/issues/13053>`_: Fixed a regression in pytest 8.3.4 where, when using ``--import-mode=importlib``, a directory containing py file with the same name would cause an ``ImportError``
1305
1306
1307 - `#13083 <https://github.com/pytest-dev/pytest/issues/13083>`_: Fixed issue where pytest could crash if one of the collected directories got removed during collection.
1308
1309
1310
1311 Improved documentation
1312 ----------------------
1313
1314 - `#12842 <https://github.com/pytest-dev/pytest/issues/12842>`_: Added dedicated page about using types with pytest.
1315
1316 See :ref:`types` for detailed usage.
1317
1318
1319
1320 Contributor-facing changes
1321 --------------------------
1322
1323 - `#13112 <https://github.com/pytest-dev/pytest/issues/13112>`_: Fixed selftest failures in ``test_terminal.py`` with Pygments >= 2.19.0
1324
1325
1326 - `#13256 <https://github.com/pytest-dev/pytest/issues/13256>`_: Support for Towncrier versions released in 2024 has been re-enabled
1327 when building Sphinx docs -- by :user:`webknjaz`.
1328
1329
1330 pytest 8.3.4 (2024-12-01)
1331 =========================
1332
1333 Bug fixes
1334 ---------
1335
1336 - `#12592 <https://github.com/pytest-dev/pytest/issues/12592>`_: Fixed :class:`KeyError` crash when using ``--import-mode=importlib`` in a directory layout where a directory contains a child directory with the same name.
1337
1338
1339 - `#12818 <https://github.com/pytest-dev/pytest/issues/12818>`_: Assertion rewriting now preserves the source ranges of the original instructions, making it play well with tools that deal with the ``AST``, like `executing <https://github.com/alexmojaki/executing>`__.
1340
1341
1342 - `#12849 <https://github.com/pytest-dev/pytest/issues/12849>`_: ANSI escape codes for colored output now handled correctly in :func:`pytest.fail` with `pytrace=False`.
1343
1344
1345 - `#9353 <https://github.com/pytest-dev/pytest/issues/9353>`_: :func:`pytest.approx` now uses strict equality when given booleans.
1346
1347
1348
1349 Improved documentation
1350 ----------------------
1351
1352 - `#10558 <https://github.com/pytest-dev/pytest/issues/10558>`_: Fix ambiguous docstring of :func:`pytest.Config.getoption`.
1353
1354
1355 - `#10829 <https://github.com/pytest-dev/pytest/issues/10829>`_: Improve documentation on the current handling of the ``--basetemp`` option and its lack of retention functionality (:ref:`temporary directory location and retention`).
1356
1357
1358 - `#12866 <https://github.com/pytest-dev/pytest/issues/12866>`_: Improved cross-references concerning the :fixture:`recwarn` fixture.
1359
1360
1361 - `#12966 <https://github.com/pytest-dev/pytest/issues/12966>`_: Clarify :ref:`filterwarnings` docs on filter precedence/order when using multiple :ref:`@pytest.mark.filterwarnings <pytest.mark.filterwarnings ref>` marks.
1362
1363
1364
1365 Contributor-facing changes
1366 --------------------------
1367
1368 - `#12497 <https://github.com/pytest-dev/pytest/issues/12497>`_: Fixed two failing pdb-related tests on Python 3.13.
1369
1370
1371 pytest 8.3.3 (2024-09-09)
1372 =========================
1373
1374 Bug fixes
1375 ---------
1376
1377 - `#12446 <https://github.com/pytest-dev/pytest/issues/12446>`_: Avoid calling ``@property`` (and other instance descriptors) during fixture discovery -- by :user:`asottile`
1378
1379
1380 - `#12659 <https://github.com/pytest-dev/pytest/issues/12659>`_: Fixed the issue of not displaying assertion failure differences when using the parameter ``--import-mode=importlib`` in pytest>=8.1.
1381
1382
1383 - `#12667 <https://github.com/pytest-dev/pytest/issues/12667>`_: Fixed a regression where type change in `ExceptionInfo.errisinstance` caused `mypy` to fail.
1384
1385
1386 - `#12744 <https://github.com/pytest-dev/pytest/issues/12744>`_: Fixed typing compatibility with Python 3.9 or less -- replaced `typing.Self` with `typing_extensions.Self` -- by :user:`Avasam`
1387
1388
1389 - `#12745 <https://github.com/pytest-dev/pytest/issues/12745>`_: Fixed an issue with backslashes being incorrectly converted in nodeid paths on Windows, ensuring consistent path handling across environments.
1390
1391
1392 - `#6682 <https://github.com/pytest-dev/pytest/issues/6682>`_: Fixed bug where the verbosity levels where not being respected when printing the "msg" part of failed assertion (as in ``assert condition, msg``).
1393
1394
1395 - `#9422 <https://github.com/pytest-dev/pytest/issues/9422>`_: Fix bug where disabling the terminal plugin via ``-p no:terminal`` would cause crashes related to missing the ``verbose`` option.
1396
1397 -- by :user:`GTowers1`
1398
1399
1400
1401 Improved documentation
1402 ----------------------
1403
1404 - `#12663 <https://github.com/pytest-dev/pytest/issues/12663>`_: Clarify that the `pytest_deselected` hook should be called from `pytest_collection_modifyitems` hook implementations when items are deselected.
1405
1406
1407 - `#12678 <https://github.com/pytest-dev/pytest/issues/12678>`_: Remove erroneous quotes from `tmp_path_retention_policy` example in docs.
1408
1409
1410
1411 Miscellaneous internal changes
1412 ------------------------------
1413
1414 - `#12769 <https://github.com/pytest-dev/pytest/issues/12769>`_: Fix typos discovered by codespell and add codespell to pre-commit hooks.
1415
1416
1417 pytest 8.3.2 (2024-07-24)
1418 =========================
1419
1420 Bug fixes
1421 ---------
1422
1423 - `#12652 <https://github.com/pytest-dev/pytest/issues/12652>`_: Resolve regression `conda` environments where no longer being automatically detected.
1424
1425 -- by :user:`RonnyPfannschmidt`
1426
1427
1428 pytest 8.3.1 (2024-07-20)
1429 =========================
1430
1431 The 8.3.0 release failed to include the change notes and docs for the release. This patch release remedies this. There are no other changes.
1432
1433
1434 pytest 8.3.0 (2024-07-20)
1435 =========================
1436
1437 New features
1438 ------------
1439
1440 - `#12231 <https://github.com/pytest-dev/pytest/issues/12231>`_: Added `--xfail-tb` flag, which turns on traceback output for XFAIL results.
1441
1442 * If the `--xfail-tb` flag is not given, tracebacks for XFAIL results are NOT shown.
1443 * The style of traceback for XFAIL is set with `--tb`, and can be `auto|long|short|line|native|no`.
1444 * Note: Even if you have `--xfail-tb` set, you won't see them if `--tb=no`.
1445
1446 Some history:
1447
1448 With pytest 8.0, `-rx` or `-ra` would not only turn on summary reports for xfail, but also report the tracebacks for xfail results. This caused issues with some projects that utilize xfail, but don't want to see all of the xfail tracebacks.
1449
1450 This change detaches xfail tracebacks from `-rx`, and now we turn on xfail tracebacks with `--xfail-tb`. With this, the default `-rx`/ `-ra` behavior is identical to pre-8.0 with respect to xfail tracebacks. While this is a behavior change, it brings default behavior back to pre-8.0.0 behavior, which ultimately was considered the better course of action.
1451
1452 -- by :user:`okken`
1453
1454
1455 - `#12281 <https://github.com/pytest-dev/pytest/issues/12281>`_: Added support for keyword matching in marker expressions.
1456
1457 Now tests can be selected by marker keyword arguments.
1458 Supported values are :class:`int`, (unescaped) :class:`str`, :class:`bool` & :data:`None`.
1459
1460 See :ref:`marker examples <marker_keyword_expression_example>` for more information.
1461
1462 -- by :user:`lovetheguitar`
1463
1464
1465 - `#12567 <https://github.com/pytest-dev/pytest/issues/12567>`_: Added ``--no-fold-skipped`` command line option.
1466
1467 If this option is set, then skipped tests in short summary are no longer grouped
1468 by reason but all tests are printed individually with their nodeid in the same
1469 way as other statuses.
1470
1471 -- by :user:`pbrezina`
1472
1473
1474
1475 Improvements in existing functionality
1476 --------------------------------------
1477
1478 - `#12469 <https://github.com/pytest-dev/pytest/issues/12469>`_: The console output now uses the "third-party plugins" terminology,
1479 replacing the previously established but confusing and outdated
1480 reference to :std:doc:`setuptools <setuptools:index>`
1481 -- by :user:`webknjaz`.
1482
1483
1484 - `#12544 <https://github.com/pytest-dev/pytest/issues/12544>`_, `#12545 <https://github.com/pytest-dev/pytest/issues/12545>`_: Python virtual environment detection was improved by
1485 checking for a :file:`pyvenv.cfg` file, ensuring reliable detection on
1486 various platforms -- by :user:`zachsnickers`.
1487
1488
1489 - `#2871 <https://github.com/pytest-dev/pytest/issues/2871>`_: Do not truncate arguments to functions in output when running with `-vvv`.
1490
1491
1492 - `#389 <https://github.com/pytest-dev/pytest/issues/389>`_: The readability of assertion introspection of bound methods has been enhanced
1493 -- by :user:`farbodahm`, :user:`webknjaz`, :user:`obestwalter`, :user:`flub`
1494 and :user:`glyphack`.
1495
1496 Earlier, it was like:
1497
1498 .. code-block:: console
1499
1500 =================================== FAILURES ===================================
1501 _____________________________________ test _____________________________________
1502
1503 def test():
1504 > assert Help().fun() == 2
1505 E assert 1 == 2
1506 E + where 1 = <bound method Help.fun of <example.Help instance at 0x256a830>>()
1507 E + where <bound method Help.fun of <example.Help instance at 0x256a830>> = <example.Help instance at 0x256a830>.fun
1508 E + where <example.Help instance at 0x256a830> = Help()
1509
1510 example.py:7: AssertionError
1511 =========================== 1 failed in 0.03 seconds ===========================
1512
1513
1514 And now it's like:
1515
1516 .. code-block:: console
1517
1518 =================================== FAILURES ===================================
1519 _____________________________________ test _____________________________________
1520
1521 def test():
1522 > assert Help().fun() == 2
1523 E assert 1 == 2
1524 E + where 1 = fun()
1525 E + where fun = <test_local.Help object at 0x1074be230>.fun
1526 E + where <test_local.Help object at 0x1074be230> = Help()
1527
1528 test_local.py:13: AssertionError
1529 =========================== 1 failed in 0.03 seconds ===========================
1530
1531
1532 - `#7662 <https://github.com/pytest-dev/pytest/issues/7662>`_: Added timezone information to the testsuite timestamp in the JUnit XML report.
1533
1534
1535
1536 Bug fixes
1537 ---------
1538
1539 - `#11706 <https://github.com/pytest-dev/pytest/issues/11706>`_: Fixed reporting of teardown errors in higher-scoped fixtures when using `--maxfail` or `--stepwise`.
1540
1541 Originally added in pytest 8.0.0, but reverted in 8.0.2 due to a regression in pytest-xdist.
1542 This regression was fixed in pytest-xdist 3.6.1.
1543
1544
1545 - `#11797 <https://github.com/pytest-dev/pytest/issues/11797>`_: :func:`pytest.approx` now correctly handles :class:`Sequence <collections.abc.Sequence>`-like objects.
1546
1547
1548 - `#12204 <https://github.com/pytest-dev/pytest/issues/12204>`_, `#12264 <https://github.com/pytest-dev/pytest/issues/12264>`_: Fixed a regression in pytest 8.0 where tracebacks get longer and longer when multiple
1549 tests fail due to a shared higher-scope fixture which raised -- by :user:`bluetech`.
1550
1551 Also fixed a similar regression in pytest 5.4 for collectors which raise during setup.
1552
1553 The fix necessitated internal changes which may affect some plugins:
1554
1555 * ``FixtureDef.cached_result[2]`` is now a tuple ``(exc, tb)``
1556 instead of ``exc``.
1557 * ``SetupState.stack`` failures are now a tuple ``(exc, tb)``
1558 instead of ``exc``.
1559
1560
1561 - `#12275 <https://github.com/pytest-dev/pytest/issues/12275>`_: Fixed collection error upon encountering an :mod:`abstract <abc>` class, including abstract `unittest.TestCase` subclasses.
1562
1563
1564 - `#12328 <https://github.com/pytest-dev/pytest/issues/12328>`_: Fixed a regression in pytest 8.0.0 where package-scoped parameterized items were not correctly reordered to minimize setups/teardowns in some cases.
1565
1566
1567 - `#12424 <https://github.com/pytest-dev/pytest/issues/12424>`_: Fixed crash with `assert testcase is not None` assertion failure when re-running unittest tests using plugins like pytest-rerunfailures. Regressed in 8.2.2.
1568
1569
1570 - `#12472 <https://github.com/pytest-dev/pytest/issues/12472>`_: Fixed a crash when returning category ``"error"`` or ``"failed"`` with a custom test status from :hook:`pytest_report_teststatus` hook -- :user:`pbrezina`.
1571
1572
1573 - `#12505 <https://github.com/pytest-dev/pytest/issues/12505>`_: Improved handling of invalid regex patterns in :func:`pytest.raises(match=r'...') <pytest.raises>` by providing a clear error message.
1574
1575
1576 - `#12580 <https://github.com/pytest-dev/pytest/issues/12580>`_: Fixed a crash when using the cache class on Windows and the cache directory was created concurrently.
1577
1578
1579 - `#6962 <https://github.com/pytest-dev/pytest/issues/6962>`_: Parametrization parameters are now compared using `==` instead of `is` (`is` is still used as a fallback if the parameter does not support `==`).
1580 This fixes use of parameters such as lists, which have a different `id` but compare equal, causing fixtures to be re-computed instead of being cached.
1581
1582
1583 - `#7166 <https://github.com/pytest-dev/pytest/issues/7166>`_: Fixed progress percentages (the ``[ 87%]`` at the edge of the screen) sometimes not aligning correctly when running with pytest-xdist ``-n``.
1584
1585
1586
1587 Improved documentation
1588 ----------------------
1589
1590 - `#12153 <https://github.com/pytest-dev/pytest/issues/12153>`_: Documented using :envvar:`PYTEST_VERSION` to detect if code is running from within a pytest run.
1591
1592
1593 - `#12469 <https://github.com/pytest-dev/pytest/issues/12469>`_: The external plugin mentions in the documentation now avoid mentioning
1594 :std:doc:`setuptools entry-points <setuptools:index>` as the concept is
1595 much more generic nowadays. Instead, the terminology of "external",
1596 "installed", or "third-party" plugins (or packages) replaces that.
1597
1598 -- by :user:`webknjaz`
1599
1600
1601 - `#12577 <https://github.com/pytest-dev/pytest/issues/12577>`_: `CI` and `BUILD_NUMBER` environment variables role is described in
1602 the reference doc. They now also appear when doing `pytest -h`
1603 -- by :user:`MarcBresson`.
1604
1605
1606
1607 Contributor-facing changes
1608 --------------------------
1609
1610 - `#12467 <https://github.com/pytest-dev/pytest/issues/12467>`_: Migrated all internal type-annotations to the python3.10+ style by using the `annotations` future import.
1611
1612 -- by :user:`RonnyPfannschmidt`
1613
1614
1615 - `#11771 <https://github.com/pytest-dev/pytest/issues/11771>`_, `#12557 <https://github.com/pytest-dev/pytest/issues/12557>`_: The PyPy runtime version has been updated to 3.9 from 3.8 that introduced
1616 a flaky bug at the garbage collector which was not expected to fix there
1617 as the 3.8 is EoL.
1618
1619 -- by :user:`x612skm`
1620
1621
1622 - `#12493 <https://github.com/pytest-dev/pytest/issues/12493>`_: The change log draft preview integration has been refactored to use a
1623 third party extension ``sphinxcontib-towncrier``. The previous in-repo
1624 script was putting the change log preview file at
1625 :file:`doc/en/_changelog_towncrier_draft.rst`. Said file is no longer
1626 ignored in Git and might show up among untracked files in the
1627 development environments of the contributors. To address that, the
1628 contributors can run the following command that will clean it up:
1629
1630 .. code-block:: console
1631
1632 $ git clean -x -i -- doc/en/_changelog_towncrier_draft.rst
1633
1634 -- by :user:`webknjaz`
1635
1636
1637 - `#12498 <https://github.com/pytest-dev/pytest/issues/12498>`_: All the undocumented ``tox`` environments now have descriptions.
1638 They can be listed in one's development environment by invoking
1639 ``tox -av`` in a terminal.
1640
1641 -- by :user:`webknjaz`
1642
1643
1644 - `#12501 <https://github.com/pytest-dev/pytest/issues/12501>`_: The changelog configuration has been updated to introduce more accurate
1645 audience-tailored categories. Previously, there was a ``trivial``
1646 change log fragment type with an unclear and broad meaning. It was
1647 removed and we now have ``contrib``, ``misc`` and ``packaging`` in
1648 place of it.
1649
1650 The new change note types target the readers who are downstream
1651 packagers and project contributors. Additionally, the miscellaneous
1652 section is kept for unspecified updates that do not fit anywhere else.
1653
1654 -- by :user:`webknjaz`
1655
1656
1657 - `#12502 <https://github.com/pytest-dev/pytest/issues/12502>`_: The UX of the GitHub automation making pull requests to update the
1658 plugin list has been updated. Previously, the maintainers had to close
1659 the automatically created pull requests and re-open them to trigger the
1660 CI runs. From now on, they only need to click the `Ready for review`
1661 button instead.
1662
1663 -- by :user:`webknjaz`
1664
1665
1666 - `#12522 <https://github.com/pytest-dev/pytest/issues/12522>`_: The ``:pull:`` RST role has been replaced with a shorter
1667 ``:pr:`` due to starting to use the implementation from
1668 the third-party :pypi:`sphinx-issues` Sphinx extension
1669 -- by :user:`webknjaz`.
1670
1671
1672 - `#12531 <https://github.com/pytest-dev/pytest/issues/12531>`_: The coverage reporting configuration has been updated to exclude
1673 pytest's own tests marked as expected to fail from the coverage
1674 report. This has an effect of reducing the influence of flaky
1675 tests on the resulting number.
1676
1677 -- by :user:`webknjaz`
1678
1679
1680 - `#12533 <https://github.com/pytest-dev/pytest/issues/12533>`_: The ``extlinks`` Sphinx extension is no longer enabled. The ``:bpo:``
1681 role it used to declare has been removed with that. BPO itself has
1682 migrated to GitHub some years ago and it is possible to link the
1683 respective issues by using their GitHub issue numbers and the
1684 ``:issue:`` role that the ``sphinx-issues`` extension implements.
1685
1686 -- by :user:`webknjaz`
1687
1688
1689 - `#12562 <https://github.com/pytest-dev/pytest/issues/12562>`_: Possible typos in using the ``:user:`` RST role is now being linted
1690 through the pre-commit tool integration -- by :user:`webknjaz`.
1691
1692
1693 pytest 8.2.2 (2024-06-04)
1694 =========================
1695
1696 Bug Fixes
1697 ---------
1698
1699 - `#12355 <https://github.com/pytest-dev/pytest/issues/12355>`_: Fix possible catastrophic performance slowdown on a certain parametrization pattern involving many higher-scoped parameters.
1700
1701
1702 - `#12367 <https://github.com/pytest-dev/pytest/issues/12367>`_: Fix a regression in pytest 8.2.0 where unittest class instances (a fresh one is created for each test) were not released promptly on test teardown but only on session teardown.
1703
1704
1705 - `#12381 <https://github.com/pytest-dev/pytest/issues/12381>`_: Fix possible "Directory not empty" crashes arising from concurrent cache dir (``.pytest_cache``) creation. Regressed in pytest 8.2.0.
1706
1707
1708
1709 Improved Documentation
1710 ----------------------
1711
1712 - `#12290 <https://github.com/pytest-dev/pytest/issues/12290>`_: Updated Sphinx theme to use Furo instead of Flask, enabling Dark mode theme.
1713
1714
1715 - `#12356 <https://github.com/pytest-dev/pytest/issues/12356>`_: Added a subsection to the documentation for debugging flaky tests to mention
1716 lack of thread safety in pytest as a possible source of flakiness.
1717
1718
1719 - `#12363 <https://github.com/pytest-dev/pytest/issues/12363>`_: The documentation webpages now links to a canonical version to reduce outdated documentation in search engine results.
1720
1721
1722 pytest 8.2.1 (2024-05-19)
1723 =========================
1724
1725 Improvements
1726 ------------
1727
1728 - `#12334 <https://github.com/pytest-dev/pytest/issues/12334>`_: Support for Python 3.13 (beta1 at the time of writing).
1729
1730
1731
1732 Bug Fixes
1733 ---------
1734
1735 - `#12120 <https://github.com/pytest-dev/pytest/issues/12120>`_: Fix `PermissionError` crashes arising from directories which are not selected on the command-line.
1736
1737
1738 - `#12191 <https://github.com/pytest-dev/pytest/issues/12191>`_: Keyboard interrupts and system exits are now properly handled during the test collection.
1739
1740
1741 - `#12300 <https://github.com/pytest-dev/pytest/issues/12300>`_: Fixed handling of 'Function not implemented' error under squashfuse_ll, which is a different way to say that the mountpoint is read-only.
1742
1743
1744 - `#12308 <https://github.com/pytest-dev/pytest/issues/12308>`_: Fix a regression in pytest 8.2.0 where the permissions of automatically-created ``.pytest_cache`` directories became ``rwx------`` instead of the expected ``rwxr-xr-x``.
1745
1746
1747
1748 Trivial/Internal Changes
1749 ------------------------
1750
1751 - `#12333 <https://github.com/pytest-dev/pytest/issues/12333>`_: pytest releases are now attested using the recent `Artifact Attestation <https://github.blog/2024-05-02-introducing-artifact-attestations-now-in-public-beta/>`_ support from GitHub, allowing users to verify the provenance of pytest's sdist and wheel artifacts.
1752
1753
1754 pytest 8.2.0 (2024-04-27)
1755 =========================
1756
1757 Breaking Changes
1758 ----------------
1759
1760 - `#12089 <https://github.com/pytest-dev/pytest/pull/12089>`_: pytest now requires that :class:`unittest.TestCase` subclasses can be instantiated freely using ``MyTestCase('runTest')``.
1761
1762 If the class doesn't allow this, you may see an error during collection such as ``AttributeError: 'MyTestCase' object has no attribute 'runTest'``.
1763
1764 Classes which do not override ``__init__``, or do not access the test method in ``__init__`` using ``getattr`` or similar, are unaffected.
1765
1766 Classes which do should take care to not crash when ``"runTest"`` is given, as is shown in `unittest.TestCases's implementation <https://github.com/python/cpython/blob/51aefc5bf907ddffaaf083ded0de773adcdf08c8/Lib/unittest/case.py#L419-L426>`_.
1767 Alternatively, consider using :meth:`setUp <unittest.TestCase.setUp>` instead of ``__init__``.
1768
1769 If you run into this issue using ``tornado.AsyncTestCase``, please see `issue 12263 <https://github.com/pytest-dev/pytest/issues/12263>`_.
1770
1771 If you run into this issue using an abstract ``TestCase`` subclass, please see `issue 12275 <https://github.com/pytest-dev/pytest/issues/12275>`_.
1772
1773 Historical note: the effect of this change on custom TestCase implementations was not properly considered initially, this is why it was done in a minor release. We apologize for the inconvenience.
1774
1775 Deprecations
1776 ------------
1777
1778 - `#12069 <https://github.com/pytest-dev/pytest/issues/12069>`_: A deprecation warning is now raised when implementations of one of the following hooks request a deprecated ``py.path.local`` parameter instead of the ``pathlib.Path`` parameter which replaced it:
1779
1780 - :hook:`pytest_ignore_collect` - the ``path`` parameter - use ``collection_path`` instead.
1781 - :hook:`pytest_collect_file` - the ``path`` parameter - use ``file_path`` instead.
1782 - :hook:`pytest_pycollect_makemodule` - the ``path`` parameter - use ``module_path`` instead.
1783 - :hook:`pytest_report_header` - the ``startdir`` parameter - use ``start_path`` instead.
1784 - :hook:`pytest_report_collectionfinish` - the ``startdir`` parameter - use ``start_path`` instead.
1785
1786 The replacement parameters are available since pytest 7.0.0.
1787 The old parameters will be removed in pytest 9.0.0.
1788
1789 See :ref:`legacy-path-hooks-deprecated` for more details.
1790
1791
1792
1793 Features
1794 --------
1795
1796 - `#11871 <https://github.com/pytest-dev/pytest/issues/11871>`_: Added support for reading command line arguments from a file using the prefix character ``@``, like e.g.: ``pytest @tests.txt``. The file must have one argument per line.
1797
1798 See :ref:`Read arguments from file <args-from-file>` for details.
1799
1800
1801
1802 Improvements
1803 ------------
1804
1805 - `#11523 <https://github.com/pytest-dev/pytest/issues/11523>`_: :func:`pytest.importorskip` will now issue a warning if the module could be found, but raised :class:`ImportError` instead of :class:`ModuleNotFoundError`.
1806
1807 The warning can be suppressed by passing ``exc_type=ImportError`` to :func:`pytest.importorskip`.
1808
1809 See :ref:`import-or-skip-import-error` for details.
1810
1811
1812 - `#11728 <https://github.com/pytest-dev/pytest/issues/11728>`_: For ``unittest``-based tests, exceptions during class cleanup (as raised by functions registered with :meth:`TestCase.addClassCleanup <unittest.TestCase.addClassCleanup>`) are now reported instead of silently failing.
1813
1814
1815 - `#11777 <https://github.com/pytest-dev/pytest/issues/11777>`_: Text is no longer truncated in the ``short test summary info`` section when ``-vv`` is given.
1816
1817
1818 - `#12112 <https://github.com/pytest-dev/pytest/issues/12112>`_: Improved namespace packages detection when :confval:`consider_namespace_packages` is enabled, covering more situations (like editable installs).
1819
1820
1821 - `#9502 <https://github.com/pytest-dev/pytest/issues/9502>`_: Added :envvar:`PYTEST_VERSION` environment variable which is defined at the start of the pytest session and undefined afterwards. It contains the value of ``pytest.__version__``, and among other things can be used to easily check if code is running from within a pytest run.
1822
1823
1824
1825 Bug Fixes
1826 ---------
1827
1828 - `#12065 <https://github.com/pytest-dev/pytest/issues/12065>`_: Fixed a regression in pytest 8.0.0 where test classes containing ``setup_method`` and tests using ``@staticmethod`` or ``@classmethod`` would crash with ``AttributeError: 'NoneType' object has no attribute 'setup_method'``.
1829
1830 Now the :attr:`request.instance <pytest.FixtureRequest.instance>` attribute of tests using ``@staticmethod`` and ``@classmethod`` is no longer ``None``, but a fresh instance of the class, like in non-static methods.
1831 Previously it was ``None``, and all fixtures of such tests would share a single ``self``.
1832
1833
1834 - `#12135 <https://github.com/pytest-dev/pytest/issues/12135>`_: Fixed issue where fixtures adding their finalizer multiple times to fixtures they request would cause unreliable and non-intuitive teardown ordering in some instances.
1835
1836
1837 - `#12194 <https://github.com/pytest-dev/pytest/issues/12194>`_: Fixed a bug with ``--importmode=importlib`` and ``--doctest-modules`` where child modules did not appear as attributes in parent modules.
1838
1839
1840 - `#1489 <https://github.com/pytest-dev/pytest/issues/1489>`_: Fixed some instances where teardown of higher-scoped fixtures was not happening in the reverse order they were initialized in.
1841
1842
1843
1844 Trivial/Internal Changes
1845 ------------------------
1846
1847 - `#12069 <https://github.com/pytest-dev/pytest/issues/12069>`_: ``pluggy>=1.5.0`` is now required.
1848
1849
1850 - `#12167 <https://github.com/pytest-dev/pytest/issues/12167>`_: :ref:`cache <cache>`: create supporting files (``CACHEDIR.TAG``, ``.gitignore``, etc.) in a temporary directory to provide atomic semantics.
1851
1852
1853 pytest 8.1.2 (2024-04-26)
1854 =========================
1855
1856 Bug Fixes
1857 ---------
1858
1859 - `#12114 <https://github.com/pytest-dev/pytest/issues/12114>`_: Fixed error in :func:`pytest.approx` when used with `numpy` arrays and comparing with other types.
1860
1861
1862 pytest 8.1.1 (2024-03-08)
1863 =========================
1864
1865 .. note::
1866
1867 This release is not a usual bug fix release -- it contains features and improvements, being a follow up
1868 to ``8.1.0``, which has been yanked from PyPI.
1869
1870 Features
1871 --------
1872
1873 - `#11475 <https://github.com/pytest-dev/pytest/issues/11475>`_: Added the new :confval:`consider_namespace_packages` configuration option, defaulting to ``False``.
1874
1875 If set to ``True``, pytest will attempt to identify modules that are part of `namespace packages <https://packaging.python.org/en/latest/guides/packaging-namespace-packages>`__ when importing modules.
1876
1877
1878 - `#11653 <https://github.com/pytest-dev/pytest/issues/11653>`_: Added the new :confval:`verbosity_test_cases` configuration option for fine-grained control of test execution verbosity.
1879 See :ref:`Fine-grained verbosity <pytest.fine_grained_verbosity>` for more details.
1880
1881
1882
1883 Improvements
1884 ------------
1885
1886 - `#10865 <https://github.com/pytest-dev/pytest/issues/10865>`_: :func:`pytest.warns` now validates that :func:`warnings.warn` was called with a `str` or a `Warning`.
1887 Currently in Python it is possible to use other types, however this causes an exception when :func:`warnings.filterwarnings` is used to filter those warnings (see `CPython #103577 <https://github.com/python/cpython/issues/103577>`__ for a discussion).
1888 While this can be considered a bug in CPython, we decided to put guards in pytest as the error message produced without this check in place is confusing.
1889
1890
1891 - `#11311 <https://github.com/pytest-dev/pytest/issues/11311>`_: When using ``--override-ini`` for paths in invocations without a configuration file defined, the current working directory is used
1892 as the relative directory.
1893
1894 Previously this would raise an :class:`AssertionError`.
1895
1896
1897 - `#11475 <https://github.com/pytest-dev/pytest/issues/11475>`_: :ref:`--import-mode=importlib <import-mode-importlib>` now tries to import modules using the standard import mechanism (but still without changing :py:data:`sys.path`), falling back to importing modules directly only if that fails.
1898
1899 This means that installed packages will be imported under their canonical name if possible first, for example ``app.core.models``, instead of having the module name always be derived from their path (for example ``.env310.lib.site_packages.app.core.models``).
1900
1901
1902 - `#11801 <https://github.com/pytest-dev/pytest/issues/11801>`_: Added the :func:`iter_parents() <_pytest.nodes.Node.iter_parents>` helper method on nodes.
1903 It is similar to :func:`listchain <_pytest.nodes.Node.listchain>`, but goes from bottom to top, and returns an iterator, not a list.
1904
1905
1906 - `#11850 <https://github.com/pytest-dev/pytest/issues/11850>`_: Added support for :data:`sys.last_exc` for post-mortem debugging on Python>=3.12.
1907
1908
1909 - `#11962 <https://github.com/pytest-dev/pytest/issues/11962>`_: In case no other suitable candidates for configuration file are found, a ``pyproject.toml`` (even without a ``[tool.pytest.ini_options]`` table) will be considered as the configuration file and define the ``rootdir``.
1910
1911
1912 - `#11978 <https://github.com/pytest-dev/pytest/issues/11978>`_: Add ``--log-file-mode`` option to the logging plugin, enabling appending to log-files. This option accepts either ``"w"`` or ``"a"`` and defaults to ``"w"``.
1913
1914 Previously, the mode was hard-coded to be ``"w"`` which truncates the file before logging.
1915
1916
1917 - `#12047 <https://github.com/pytest-dev/pytest/issues/12047>`_: When multiple finalizers of a fixture raise an exception, now all exceptions are reported as an exception group.
1918 Previously, only the first exception was reported.
1919
1920
1921
1922 Bug Fixes
1923 ---------
1924
1925 - `#11475 <https://github.com/pytest-dev/pytest/issues/11475>`_: Fixed regression where ``--importmode=importlib`` would import non-test modules more than once.
1926
1927
1928 - `#11904 <https://github.com/pytest-dev/pytest/issues/11904>`_: Fixed a regression in pytest 8.0.0 that would cause test collection to fail due to permission errors when using ``--pyargs``.
1929
1930 This change improves the collection tree for tests specified using ``--pyargs``, see :pr:`12043` for a comparison with pytest 8.0 and <8.
1931
1932
1933 - `#12011 <https://github.com/pytest-dev/pytest/issues/12011>`_: Fixed a regression in 8.0.1 whereby ``setup_module`` xunit-style fixtures are not executed when ``--doctest-modules`` is passed.
1934
1935
1936 - `#12014 <https://github.com/pytest-dev/pytest/issues/12014>`_: Fix the ``stacklevel`` used when warning about marks used on fixtures.
1937
1938
1939 - `#12039 <https://github.com/pytest-dev/pytest/issues/12039>`_: Fixed a regression in ``8.0.2`` where tests created using :fixture:`tmp_path` have been collected multiple times in CI under Windows.
1940
1941
1942 Improved Documentation
1943 ----------------------
1944
1945 - `#11790 <https://github.com/pytest-dev/pytest/issues/11790>`_: Documented the retention of temporary directories created using the ``tmp_path`` fixture in more detail.
1946
1947
1948
1949 Trivial/Internal Changes
1950 ------------------------
1951
1952 - `#11785 <https://github.com/pytest-dev/pytest/issues/11785>`_: Some changes were made to private functions which may affect plugins which access them:
1953
1954 - ``FixtureManager._getautousenames()`` now takes a ``Node`` itself instead of the nodeid.
1955 - ``FixtureManager.getfixturedefs()`` now takes the ``Node`` itself instead of the nodeid.
1956 - The ``_pytest.nodes.iterparentnodeids()`` function is removed without replacement.
1957 Prefer to traverse the node hierarchy itself instead.
1958 If you really need to, copy the function from the previous pytest release.
1959
1960
1961 - `#12069 <https://github.com/pytest-dev/pytest/issues/12069>`_: Delayed the deprecation of the following features to ``9.0.0``:
1962
1963 * :ref:`node-ctor-fspath-deprecation`.
1964 * :ref:`legacy-path-hooks-deprecated`.
1965
1966 It was discovered after ``8.1.0`` was released that the warnings about the impeding removal were not being displayed, so the team decided to revert the removal.
1967
1968 This is the reason for ``8.1.0`` being yanked.
1969
1970
1971 pytest 8.1.0 (YANKED)
1972 =====================
1973
1974
1975 .. note::
1976
1977 This release has been **yanked**: it broke some plugins without the proper warning period, due to
1978 some warnings not showing up as expected.
1979
1980 See `#12069 <https://github.com/pytest-dev/pytest/issues/12069>`__.
1981
1982
1983 pytest 8.0.2 (2024-02-24)
1984 =========================
1985
1986 Bug Fixes
1987 ---------
1988
1989 - `#11895 <https://github.com/pytest-dev/pytest/issues/11895>`_: Fix collection on Windows where initial paths contain the short version of a path (for example ``c:\PROGRA~1\tests``).
1990
1991
1992 - `#11953 <https://github.com/pytest-dev/pytest/issues/11953>`_: Fix an ``IndexError`` crash raising from ``getstatementrange_ast``.
1993
1994
1995 - `#12021 <https://github.com/pytest-dev/pytest/issues/12021>`_: Reverted a fix to `--maxfail` handling in pytest 8.0.0 because it caused a regression in pytest-xdist whereby session fixture teardowns may get executed multiple times when the max-fails is reached.
1996
1997
1998 pytest 8.0.1 (2024-02-16)
1999 =========================
2000
2001 Bug Fixes
2002 ---------
2003
2004 - `#11875 <https://github.com/pytest-dev/pytest/issues/11875>`_: Correctly handle errors from :func:`getpass.getuser` in Python 3.13.
2005
2006
2007 - `#11879 <https://github.com/pytest-dev/pytest/issues/11879>`_: Fix an edge case where ``ExceptionInfo._stringify_exception`` could crash :func:`pytest.raises`.
2008
2009
2010 - `#11906 <https://github.com/pytest-dev/pytest/issues/11906>`_: Fix regression with :func:`pytest.warns` using custom warning subclasses which have more than one parameter in their `__init__`.
2011
2012
2013 - `#11907 <https://github.com/pytest-dev/pytest/issues/11907>`_: Fix a regression in pytest 8.0.0 whereby calling :func:`pytest.skip` and similar control-flow exceptions within a :func:`pytest.warns()` block would get suppressed instead of propagating.
2014
2015
2016 - `#11929 <https://github.com/pytest-dev/pytest/issues/11929>`_: Fix a regression in pytest 8.0.0 whereby autouse fixtures defined in a module get ignored by the doctests in the module.
2017
2018
2019 - `#11937 <https://github.com/pytest-dev/pytest/issues/11937>`_: Fix a regression in pytest 8.0.0 whereby items would be collected in reverse order in some circumstances.
2020
2021
2022 pytest 8.0.0 (2024-01-27)
2023 =========================
2024
2025 Bug Fixes
2026 ---------
2027
2028 - `#11842 <https://github.com/pytest-dev/pytest/issues/11842>`_: Properly escape the ``reason`` of a :ref:`skip <pytest.mark.skip ref>` mark when writing JUnit XML files.
2029
2030
2031 - `#11861 <https://github.com/pytest-dev/pytest/issues/11861>`_: Avoid microsecond exceeds ``1_000_000`` when using ``log-date-format`` with ``%f`` specifier, which might cause the test suite to crash.
2032
2033
2034 pytest 8.0.0rc2 (2024-01-17)
2035 ============================
2036
2037
2038 Improvements
2039 ------------
2040
2041 - `#11233 <https://github.com/pytest-dev/pytest/issues/11233>`_: Improvements to ``-r`` for xfailures and xpasses:
2042
2043 * Report tracebacks for xfailures when ``-rx`` is set.
2044 * Report captured output for xpasses when ``-rX`` is set.
2045 * For xpasses, add ``-`` in summary between test name and reason, to match how xfail is displayed.
2046
2047 - `#11825 <https://github.com/pytest-dev/pytest/issues/11825>`_: The :hook:`pytest_plugin_registered` hook has a new ``plugin_name`` parameter containing the name by which ``plugin`` is registered.
2048
2049
2050 Bug Fixes
2051 ---------
2052
2053 - `#11706 <https://github.com/pytest-dev/pytest/issues/11706>`_: Fix reporting of teardown errors in higher-scoped fixtures when using `--maxfail` or `--stepwise`.
2054
2055 NOTE: This change was reverted in pytest 8.0.2 to fix a `regression <https://github.com/pytest-dev/pytest-xdist/issues/1024>`_ it caused in pytest-xdist.
2056
2057
2058 - `#11758 <https://github.com/pytest-dev/pytest/issues/11758>`_: Fixed ``IndexError: string index out of range`` crash in ``if highlighted[-1] == "\n" and source[-1] != "\n"``.
2059 This bug was introduced in pytest 8.0.0rc1.
2060
2061
2062 - `#9765 <https://github.com/pytest-dev/pytest/issues/9765>`_, `#11816 <https://github.com/pytest-dev/pytest/issues/11816>`_: Fixed a frustrating bug that afflicted some users with the only error being ``assert mod not in mods``. The issue was caused by the fact that ``str(Path(mod))`` and ``mod.__file__`` don't necessarily produce the same string, and was being erroneously used interchangeably in some places in the code.
2063
2064 This fix also broke the internal API of ``PytestPluginManager.consider_conftest`` by introducing a new parameter -- we mention this in case it is being used by external code, even if marked as *private*.
2065
2066
2067 pytest 8.0.0rc1 (2023-12-30)
2068 ============================
2069
2070 Breaking Changes
2071 ----------------
2072
2073 Old Deprecations Are Now Errors
2074 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2075
2076 - `#7363 <https://github.com/pytest-dev/pytest/issues/7363>`_: **PytestRemovedIn8Warning deprecation warnings are now errors by default.**
2077
2078 Following our plan to remove deprecated features with as little disruption as
2079 possible, all warnings of type ``PytestRemovedIn8Warning`` now generate errors
2080 instead of warning messages by default.
2081
2082 **The affected features will be effectively removed in pytest 8.1**, so please consult the
2083 :ref:`deprecations` section in the docs for directions on how to update existing code.
2084
2085 In the pytest ``8.0.X`` series, it is possible to change the errors back into warnings as a
2086 stopgap measure by adding this to your ``pytest.ini`` file:
2087
2088 .. code-block:: ini
2089
2090 [pytest]
2091 filterwarnings =
2092 ignore::pytest.PytestRemovedIn8Warning
2093
2094 But this will stop working when pytest ``8.1`` is released.
2095
2096 **If you have concerns** about the removal of a specific feature, please add a
2097 comment to :issue:`7363`.
2098
2099
2100 Version Compatibility
2101 ^^^^^^^^^^^^^^^^^^^^^
2102
2103 - `#11151 <https://github.com/pytest-dev/pytest/issues/11151>`_: Dropped support for Python 3.7, which `reached end-of-life on 2023-06-27 <https://devguide.python.org/versions/>`__.
2104
2105
2106 - ``pluggy>=1.3.0`` is now required.
2107
2108
2109 Collection Changes
2110 ^^^^^^^^^^^^^^^^^^
2111
2112 In this version we've made several breaking changes to pytest's collection phase,
2113 particularly around how filesystem directories and Python packages are collected,
2114 fixing deficiencies and allowing for cleanups and improvements to pytest's internals.
2115 A deprecation period for these changes was not possible.
2116
2117
2118 - `#7777 <https://github.com/pytest-dev/pytest/issues/7777>`_: Files and directories are now collected in alphabetical order jointly, unless changed by a plugin.
2119 Previously, files were collected before directories.
2120 See below for an example.
2121
2122
2123 - `#8976 <https://github.com/pytest-dev/pytest/issues/8976>`_: Running `pytest pkg/__init__.py` now collects the `pkg/__init__.py` file (module) only.
2124 Previously, it collected the entire `pkg` package, including other test files in the directory, but excluding tests in the `__init__.py` file itself
2125 (unless :confval:`python_files` was changed to allow `__init__.py` file).
2126
2127 To collect the entire package, specify just the directory: `pytest pkg`.
2128
2129
2130 - `#11137 <https://github.com/pytest-dev/pytest/issues/11137>`_: :class:`pytest.Package` is no longer a :class:`pytest.Module` or :class:`pytest.File`.
2131
2132 The ``Package`` collector node designates a Python package, that is, a directory with an `__init__.py` file.
2133 Previously ``Package`` was a subtype of ``pytest.Module`` (which represents a single Python module),
2134 the module being the `__init__.py` file.
2135 This has been deemed a design mistake (see :issue:`11137` and :issue:`7777` for details).
2136
2137 The ``path`` property of ``Package`` nodes now points to the package directory instead of the ``__init__.py`` file.
2138
2139 Note that a ``Module`` node for ``__init__.py`` (which is not a ``Package``) may still exist,
2140 if it is picked up during collection (e.g. if you configured :confval:`python_files` to include ``__init__.py`` files).
2141
2142
2143 - `#7777 <https://github.com/pytest-dev/pytest/issues/7777>`_: Added a new :class:`pytest.Directory` base collection node, which all collector nodes for filesystem directories are expected to subclass.
2144 This is analogous to the existing :class:`pytest.File` for file nodes.
2145
2146 Changed :class:`pytest.Package` to be a subclass of :class:`pytest.Directory`.
2147 A ``Package`` represents a filesystem directory which is a Python package,
2148 i.e. contains an ``__init__.py`` file.
2149
2150 :class:`pytest.Package` now only collects files in its own directory; previously it collected recursively.
2151 Sub-directories are collected as their own collector nodes, which then collect themselves, thus creating a collection tree which mirrors the filesystem hierarchy.
2152
2153 Added a new :class:`pytest.Dir` concrete collection node, a subclass of :class:`pytest.Directory`.
2154 This node represents a filesystem directory, which is not a :class:`pytest.Package`,
2155 that is, does not contain an ``__init__.py`` file.
2156 Similarly to ``Package``, it only collects the files in its own directory.
2157
2158 :class:`pytest.Session` now only collects the initial arguments, without recursing into directories.
2159 This work is now done by the :func:`recursive expansion process <pytest.Collector.collect>` of directory collector nodes.
2160
2161 :attr:`session.name <pytest.Session.name>` is now ``""``; previously it was the rootdir directory name.
2162 This matches :attr:`session.nodeid <_pytest.nodes.Node.nodeid>` which has always been `""`.
2163
2164 The collection tree now contains directories/packages up to the :ref:`rootdir <rootdir>`,
2165 for initial arguments that are found within the rootdir.
2166 For files outside the rootdir, only the immediate directory/package is collected --
2167 note however that collecting from outside the rootdir is discouraged.
2168
2169 As an example, given the following filesystem tree::
2170
2171 myroot/
2172 pytest.ini
2173 top/
2174 ├── aaa
2175 │ └── test_aaa.py
2176 ├── test_a.py
2177 ├── test_b
2178 │ ├── __init__.py
2179 │ └── test_b.py
2180 ├── test_c.py
2181 └── zzz
2182 ├── __init__.py
2183 └── test_zzz.py
2184
2185 the collection tree, as shown by `pytest --collect-only top/` but with the otherwise-hidden :class:`~pytest.Session` node added for clarity,
2186 is now the following::
2187
2188 <Session>
2189 <Dir myroot>
2190 <Dir top>
2191 <Dir aaa>
2192 <Module test_aaa.py>
2193 <Function test_it>
2194 <Module test_a.py>
2195 <Function test_it>
2196 <Package test_b>
2197 <Module test_b.py>
2198 <Function test_it>
2199 <Module test_c.py>
2200 <Function test_it>
2201 <Package zzz>
2202 <Module test_zzz.py>
2203 <Function test_it>
2204
2205 Previously, it was::
2206
2207 <Session>
2208 <Module top/test_a.py>
2209 <Function test_it>
2210 <Module top/test_c.py>
2211 <Function test_it>
2212 <Module top/aaa/test_aaa.py>
2213 <Function test_it>
2214 <Package test_b>
2215 <Module test_b.py>
2216 <Function test_it>
2217 <Package zzz>
2218 <Module test_zzz.py>
2219 <Function test_it>
2220
2221 Code/plugins which rely on a specific shape of the collection tree might need to update.
2222
2223
2224 - `#11676 <https://github.com/pytest-dev/pytest/issues/11676>`_: The classes :class:`~_pytest.nodes.Node`, :class:`~pytest.Collector`, :class:`~pytest.Item`, :class:`~pytest.File`, :class:`~_pytest.nodes.FSCollector` are now marked abstract (see :mod:`abc`).
2225
2226 We do not expect this change to affect users and plugin authors, it will only cause errors when the code is already wrong or problematic.
2227
2228
2229 Other breaking changes
2230 ^^^^^^^^^^^^^^^^^^^^^^
2231
2232 These are breaking changes where deprecation was not possible.
2233
2234
2235 - `#11282 <https://github.com/pytest-dev/pytest/issues/11282>`_: Sanitized the handling of the ``default`` parameter when defining configuration options.
2236
2237 Previously if ``default`` was not supplied for :meth:`parser.addini <pytest.Parser.addini>` and the configuration option value was not defined in a test session, then calls to :func:`config.getini <pytest.Config.getini>` returned an *empty list* or an *empty string* depending on whether ``type`` was supplied or not respectively, which is clearly incorrect. Also, ``None`` was not honored even if ``default=None`` was used explicitly while defining the option.
2238
2239 Now the behavior of :meth:`parser.addini <pytest.Parser.addini>` is as follows:
2240
2241 * If ``default`` is NOT passed but ``type`` is provided, then a type-specific default will be returned. For example ``type=bool`` will return ``False``, ``type=str`` will return ``""``, etc.
2242 * If ``default=None`` is passed and the option is not defined in a test session, then ``None`` will be returned, regardless of the ``type``.
2243 * If neither ``default`` nor ``type`` are provided, assume ``type=str`` and return ``""`` as default (this is as per previous behavior).
2244
2245 The team decided to not introduce a deprecation period for this change, as doing so would be complicated both in terms of communicating this to the community as well as implementing it, and also because the team believes this change should not break existing plugins except in rare cases.
2246
2247
2248 - `#11667 <https://github.com/pytest-dev/pytest/issues/11667>`_: pytest's ``setup.py`` file is removed.
2249 If you relied on this file, e.g. to install pytest using ``setup.py install``,
2250 please see `Why you shouldn't invoke setup.py directly <https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html#summary>`_ for alternatives.
2251
2252
2253 - `#9288 <https://github.com/pytest-dev/pytest/issues/9288>`_: :func:`~pytest.warns` now re-emits unmatched warnings when the context
2254 closes -- previously it would consume all warnings, hiding those that were not
2255 matched by the function.
2256
2257 While this is a new feature, we announce it as a breaking change
2258 because many test suites are configured to error-out on warnings, and will
2259 therefore fail on the newly-re-emitted warnings.
2260
2261
2262 - The internal ``FixtureManager.getfixtureclosure`` method has changed. Plugins which use this method or
2263 which subclass ``FixtureManager`` and overwrite that method will need to adapt to the change.
2264
2265
2266
2267 Deprecations
2268 ------------
2269
2270 - `#10465 <https://github.com/pytest-dev/pytest/issues/10465>`_: Test functions returning a value other than ``None`` will now issue a :class:`pytest.PytestWarning` instead of ``pytest.PytestRemovedIn8Warning``, meaning this will stay a warning instead of becoming an error in the future.
2271
2272
2273 - `#3664 <https://github.com/pytest-dev/pytest/issues/3664>`_: Applying a mark to a fixture function now issues a warning: marks in fixtures never had any effect, but it is a common user error to apply a mark to a fixture (for example ``usefixtures``) and expect it to work.
2274
2275 This will become an error in pytest 9.0.
2276
2277
2278
2279 Features and Improvements
2280 -------------------------
2281
2282 Improved Diffs
2283 ^^^^^^^^^^^^^^
2284
2285 These changes improve the diffs that pytest prints when an assertion fails.
2286 Note that syntax highlighting requires the ``pygments`` package.
2287
2288
2289 - `#11520 <https://github.com/pytest-dev/pytest/issues/11520>`_: The very verbose (``-vv``) diff output is now colored as a diff instead of a big chunk of red.
2290
2291 Python code in error reports is now syntax-highlighted as Python.
2292
2293 The sections in the error reports are now better separated.
2294
2295
2296 - `#1531 <https://github.com/pytest-dev/pytest/issues/1531>`_: The very verbose diff (``-vv``) for every standard library container type is improved. The indentation is now consistent and the markers are on their own separate lines, which should reduce the diffs shown to users.
2297
2298 Previously, the standard Python pretty printer was used to generate the output, which puts opening and closing
2299 markers on the same line as the first/last entry, in addition to not having consistent indentation.
2300
2301
2302 - `#10617 <https://github.com/pytest-dev/pytest/issues/10617>`_: Added more comprehensive set assertion rewrites for comparisons other than equality ``==``, with
2303 the following operations now providing better failure messages: ``!=``, ``<=``, ``>=``, ``<``, and ``>``.
2304
2305
2306 Separate Control For Assertion Verbosity
2307 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2308
2309 - `#11387 <https://github.com/pytest-dev/pytest/issues/11387>`_: Added the new :confval:`verbosity_assertions` configuration option for fine-grained control of failed assertions verbosity.
2310
2311 If you've ever wished that pytest always show you full diffs, but without making everything else verbose, this is for you.
2312
2313 See :ref:`Fine-grained verbosity <pytest.fine_grained_verbosity>` for more details.
2314
2315 For plugin authors, :attr:`config.get_verbosity <pytest.Config.get_verbosity>` can be used to retrieve the verbosity level for a specific verbosity type.
2316
2317
2318 Additional Support For Exception Groups and ``__notes__``
2319 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2320
2321 These changes improve pytest's support for exception groups.
2322
2323
2324 - `#10441 <https://github.com/pytest-dev/pytest/issues/10441>`_: Added :func:`ExceptionInfo.group_contains() <pytest.ExceptionInfo.group_contains>`, an assertion helper that tests if an :class:`ExceptionGroup` contains a matching exception.
2325
2326 See :ref:`assert-matching-exception-groups` for an example.
2327
2328
2329 - `#11227 <https://github.com/pytest-dev/pytest/issues/11227>`_: Allow :func:`pytest.raises` ``match`` argument to match against `PEP-678 <https://peps.python.org/pep-0678/>` ``__notes__``.
2330
2331
2332 Custom Directory collectors
2333 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2334
2335 - `#7777 <https://github.com/pytest-dev/pytest/issues/7777>`_: Added a new hook :hook:`pytest_collect_directory`,
2336 which is called by filesystem-traversing collector nodes,
2337 such as :class:`pytest.Session`, :class:`pytest.Dir` and :class:`pytest.Package`,
2338 to create a collector node for a sub-directory.
2339 It is expected to return a subclass of :class:`pytest.Directory`.
2340 This hook allows plugins to :ref:`customize the collection of directories <custom directory collectors>`.
2341
2342
2343 "New-style" Hook Wrappers
2344 ^^^^^^^^^^^^^^^^^^^^^^^^^
2345
2346 - `#11122 <https://github.com/pytest-dev/pytest/issues/11122>`_: pytest now uses "new-style" hook wrappers internally, available since pluggy 1.2.0.
2347 See `pluggy's 1.2.0 changelog <https://pluggy.readthedocs.io/en/latest/changelog.html#pluggy-1-2-0-2023-06-21>`_ and the :ref:`updated docs <hookwrapper>` for details.
2348
2349 Plugins which want to use new-style wrappers can do so if they require ``pytest>=8``.
2350
2351
2352 Other Improvements
2353 ^^^^^^^^^^^^^^^^^^
2354
2355 - `#11216 <https://github.com/pytest-dev/pytest/issues/11216>`_: If a test is skipped from inside an :ref:`xunit setup fixture <classic xunit>`, the test summary now shows the test location instead of the fixture location.
2356
2357
2358 - `#11314 <https://github.com/pytest-dev/pytest/issues/11314>`_: Logging to a file using the ``--log-file`` option will use ``--log-level``, ``--log-format`` and ``--log-date-format`` as fallback
2359 if ``--log-file-level``, ``--log-file-format`` and ``--log-file-date-format`` are not provided respectively.
2360
2361
2362 - `#11610 <https://github.com/pytest-dev/pytest/issues/11610>`_: Added the :func:`LogCaptureFixture.filtering() <pytest.LogCaptureFixture.filtering>` context manager which
2363 adds a given :class:`logging.Filter` object to the :fixture:`caplog` fixture.
2364
2365
2366 - `#11447 <https://github.com/pytest-dev/pytest/issues/11447>`_: :func:`pytest.deprecated_call` now also considers warnings of type :class:`FutureWarning`.
2367
2368
2369 - `#11600 <https://github.com/pytest-dev/pytest/issues/11600>`_: Improved the documentation and type signature for :func:`pytest.mark.xfail <pytest.mark.xfail>`'s ``condition`` param to use ``False`` as the default value.
2370
2371
2372 - `#7469 <https://github.com/pytest-dev/pytest/issues/7469>`_: :class:`~pytest.FixtureDef` is now exported as ``pytest.FixtureDef`` for typing purposes.
2373
2374
2375 - `#11353 <https://github.com/pytest-dev/pytest/issues/11353>`_: Added typing to :class:`~pytest.PytestPluginManager`.
2376
2377
2378 Bug Fixes
2379 ---------
2380
2381 - `#10701 <https://github.com/pytest-dev/pytest/issues/10701>`_: :meth:`pytest.WarningsRecorder.pop` will return the most-closely-matched warning in the list,
2382 rather than the first warning which is an instance of the requested type.
2383
2384
2385 - `#11255 <https://github.com/pytest-dev/pytest/issues/11255>`_: Fixed crash on `parametrize(..., scope="package")` without a package present.
2386
2387
2388 - `#11277 <https://github.com/pytest-dev/pytest/issues/11277>`_: Fixed a bug that when there are multiple fixtures for an indirect parameter,
2389 the scope of the highest-scope fixture is picked for the parameter set, instead of that of the one with the narrowest scope.
2390
2391
2392 - `#11456 <https://github.com/pytest-dev/pytest/issues/11456>`_: Parametrized tests now *really do* ensure that the ids given to each input are unique - for
2393 example, ``a, a, a0`` now results in ``a1, a2, a0`` instead of the previous (buggy) ``a0, a1, a0``.
2394 This necessarily means changing nodeids where these were previously colliding, and for
2395 readability adds an underscore when non-unique ids end in a number.
2396
2397
2398 - `#11563 <https://github.com/pytest-dev/pytest/issues/11563>`_: Fixed a crash when using an empty string for the same parametrized value more than once.
2399
2400
2401 - `#11712 <https://github.com/pytest-dev/pytest/issues/11712>`_: Fixed handling ``NO_COLOR`` and ``FORCE_COLOR`` to ignore an empty value.
2402
2403
2404 - `#9036 <https://github.com/pytest-dev/pytest/issues/9036>`_: ``pytest.warns`` and similar functions now capture warnings when an exception is raised inside a ``with`` block.
2405
2406
2407
2408 Improved Documentation
2409 ----------------------
2410
2411 - `#11011 <https://github.com/pytest-dev/pytest/issues/11011>`_: Added a warning about modifying the root logger during tests when using ``caplog``.
2412
2413
2414 - `#11065 <https://github.com/pytest-dev/pytest/issues/11065>`_: Use ``pytestconfig`` instead of ``request.config`` in cache example to be consistent with the API documentation.
2415
2416
2417 Trivial/Internal Changes
2418 ------------------------
2419
2420 - `#11208 <https://github.com/pytest-dev/pytest/issues/11208>`_: The (internal) ``FixtureDef.cached_result`` type has changed.
2421 Now the third item ``cached_result[2]``, when set, is an exception instance instead of an exception triplet.
2422
2423
2424 - `#11218 <https://github.com/pytest-dev/pytest/issues/11218>`_: (This entry is meant to assist plugins which access private pytest internals to instantiate ``FixtureRequest`` objects.)
2425
2426 :class:`~pytest.FixtureRequest` is now an abstract class which can't be instantiated directly.
2427 A new concrete ``TopRequest`` subclass of ``FixtureRequest`` has been added for the ``request`` fixture in test functions,
2428 as counterpart to the existing ``SubRequest`` subclass for the ``request`` fixture in fixture functions.
2429
2430
2431 - `#11315 <https://github.com/pytest-dev/pytest/issues/11315>`_: The :fixture:`pytester` fixture now uses the :fixture:`monkeypatch` fixture to manage the current working directory.
2432 If you use ``pytester`` in combination with :func:`monkeypatch.undo() <pytest.MonkeyPatch.undo>`, the CWD might get restored.
2433 Use :func:`monkeypatch.context() <pytest.MonkeyPatch.context>` instead.
2434
2435
2436 - `#11333 <https://github.com/pytest-dev/pytest/issues/11333>`_: Corrected the spelling of ``Config.ArgsSource.INVOCATION_DIR``.
2437 The previous spelling ``INCOVATION_DIR`` remains as an alias.
2438
2439
2440 - `#11638 <https://github.com/pytest-dev/pytest/issues/11638>`_: Fixed the selftests to pass correctly if ``FORCE_COLOR``, ``NO_COLOR`` or ``PY_COLORS`` is set in the calling environment.
2441
2442 pytest 7.4.4 (2023-12-31)
2443 =========================
2444
2445 Bug Fixes
2446 ---------
2447
2448 - `#11140 <https://github.com/pytest-dev/pytest/issues/11140>`_: Fix non-string constants at the top of file being detected as docstrings on Python>=3.8.
2449
2450
2451 - `#11572 <https://github.com/pytest-dev/pytest/issues/11572>`_: Handle an edge case where :data:`sys.stderr` and :data:`sys.__stderr__` might already be closed when :ref:`faulthandler` is tearing down.
2452
2453
2454 - `#11710 <https://github.com/pytest-dev/pytest/issues/11710>`_: Fixed tracebacks from collection errors not getting pruned.
2455
2456
2457 - `#7966 <https://github.com/pytest-dev/pytest/issues/7966>`_: Removed unhelpful error message from assertion rewrite mechanism when exceptions are raised in ``__iter__`` methods. Now they are treated un-iterable instead.
2458
2459
2460
2461 Improved Documentation
2462 ----------------------
2463
2464 - `#11091 <https://github.com/pytest-dev/pytest/issues/11091>`_: Updated documentation to refer to hyphenated options: replaced ``--junitxml`` with ``--junit-xml`` and ``--collectonly`` with ``--collect-only``.
2465
2466
2467 pytest 7.4.3 (2023-10-24)
2468 =========================
2469
2470 Bug Fixes
2471 ---------
2472
2473 - `#10447 <https://github.com/pytest-dev/pytest/issues/10447>`_: Markers are now considered in the reverse mro order to ensure base class markers are considered first -- this resolves a regression.
2474
2475
2476 - `#11239 <https://github.com/pytest-dev/pytest/issues/11239>`_: Fixed ``:=`` in asserts impacting unrelated test cases.
2477
2478
2479 - `#11439 <https://github.com/pytest-dev/pytest/issues/11439>`_: Handled an edge case where :data:`sys.stderr` might already be closed when :ref:`faulthandler` is tearing down.
2480
2481
2482 pytest 7.4.2 (2023-09-07)
2483 =========================
2484
2485 Bug Fixes
2486 ---------
2487
2488 - `#11237 <https://github.com/pytest-dev/pytest/issues/11237>`_: Fix doctest collection of `functools.cached_property` objects.
2489
2490
2491 - `#11306 <https://github.com/pytest-dev/pytest/issues/11306>`_: Fixed bug using ``--importmode=importlib`` which would cause package ``__init__.py`` files to be imported more than once in some cases.
2492
2493
2494 - `#11367 <https://github.com/pytest-dev/pytest/issues/11367>`_: Fixed bug where `user_properties` where not being saved in the JUnit XML file if a fixture failed during teardown.
2495
2496
2497 - `#11394 <https://github.com/pytest-dev/pytest/issues/11394>`_: Fixed crash when parsing long command line arguments that might be interpreted as files.
2498
2499
2500
2501 Improved Documentation
2502 ----------------------
2503
2504 - `#11391 <https://github.com/pytest-dev/pytest/issues/11391>`_: Improved disclaimer on pytest plugin reference page to better indicate this is an automated, non-curated listing.
2505
2506
2507 pytest 7.4.1 (2023-09-02)
2508 =========================
2509
2510 Bug Fixes
2511 ---------
2512
2513 - `#10337 <https://github.com/pytest-dev/pytest/issues/10337>`_: Fixed bug where fake intermediate modules generated by ``--import-mode=importlib`` would not include the
2514 child modules as attributes of the parent modules.
2515
2516
2517 - `#10702 <https://github.com/pytest-dev/pytest/issues/10702>`_: Fixed error assertion handling in :func:`pytest.approx` when ``None`` is an expected or received value when comparing dictionaries.
2518
2519
2520 - `#10811 <https://github.com/pytest-dev/pytest/issues/10811>`_: Fixed issue when using ``--import-mode=importlib`` together with ``--doctest-modules`` that caused modules
2521 to be imported more than once, causing problems with modules that have import side effects.
2522
2523
2524 pytest 7.4.0 (2023-06-23)
2525 =========================
2526
2527 Features
2528 --------
2529
2530 - `#10901 <https://github.com/pytest-dev/pytest/issues/10901>`_: Added :func:`ExceptionInfo.from_exception() <pytest.ExceptionInfo.from_exception>`, a simpler way to create an :class:`~pytest.ExceptionInfo` from an exception.
2531 This can replace :func:`ExceptionInfo.from_exc_info() <pytest.ExceptionInfo.from_exc_info()>` for most uses.
2532
2533
2534
2535 Improvements
2536 ------------
2537
2538 - `#10872 <https://github.com/pytest-dev/pytest/issues/10872>`_: Update test log report annotation to named tuple and fixed inconsistency in docs for :hook:`pytest_report_teststatus` hook.
2539
2540
2541 - `#10907 <https://github.com/pytest-dev/pytest/issues/10907>`_: When an exception traceback to be displayed is completely filtered out (by mechanisms such as ``__tracebackhide__``, internal frames, and similar), now only the exception string and the following message are shown:
2542
2543 "All traceback entries are hidden. Pass `--full-trace` to see hidden and internal frames.".
2544
2545 Previously, the last frame of the traceback was shown, even though it was hidden.
2546
2547
2548 - `#10940 <https://github.com/pytest-dev/pytest/issues/10940>`_: Improved verbose output (``-vv``) of ``skip`` and ``xfail`` reasons by performing text wrapping while leaving a clear margin for progress output.
2549
2550 Added ``TerminalReporter.wrap_write()`` as a helper for that.
2551
2552
2553 - `#10991 <https://github.com/pytest-dev/pytest/issues/10991>`_: Added handling of ``%f`` directive to print microseconds in log format options, such as ``log-date-format``.
2554
2555
2556 - `#11005 <https://github.com/pytest-dev/pytest/issues/11005>`_: Added the underlying exception to the cache provider's path creation and write warning messages.
2557
2558
2559 - `#11013 <https://github.com/pytest-dev/pytest/issues/11013>`_: Added warning when :confval:`testpaths` is set, but paths are not found by glob. In this case, pytest will fall back to searching from the current directory.
2560
2561
2562 - `#11043 <https://github.com/pytest-dev/pytest/issues/11043>`_: When `--confcutdir` is not specified, and there is no config file present, the conftest cutoff directory (`--confcutdir`) is now set to the :ref:`rootdir <rootdir>`.
2563 Previously in such cases, `conftest.py` files would be probed all the way to the root directory of the filesystem.
2564 If you are badly affected by this change, consider adding an empty config file to your desired cutoff directory, or explicitly set `--confcutdir`.
2565
2566
2567 - `#11081 <https://github.com/pytest-dev/pytest/issues/11081>`_: The :confval:`norecursedirs` check is now performed in a :hook:`pytest_ignore_collect` implementation, so plugins can affect it.
2568
2569 If after updating to this version you see that your `norecursedirs` setting is not being respected,
2570 it means that a conftest or a plugin you use has a bad `pytest_ignore_collect` implementation.
2571 Most likely, your hook returns `False` for paths it does not want to ignore,
2572 which ends the processing and doesn't allow other plugins, including pytest itself, to ignore the path.
2573 The fix is to return `None` instead of `False` for paths your hook doesn't want to ignore.
2574
2575
2576 - `#8711 <https://github.com/pytest-dev/pytest/issues/8711>`_: :func:`caplog.set_level() <pytest.LogCaptureFixture.set_level>` and :func:`caplog.at_level() <pytest.LogCaptureFixture.at_level>`
2577 will temporarily enable the requested ``level`` if ``level`` was disabled globally via
2578 ``logging.disable(LEVEL)``.
2579
2580
2581
2582 Bug Fixes
2583 ---------
2584
2585 - `#10831 <https://github.com/pytest-dev/pytest/issues/10831>`_: Terminal Reporting: Fixed bug when running in ``--tb=line`` mode where ``pytest.fail(pytrace=False)`` tests report ``None``.
2586
2587
2588 - `#11068 <https://github.com/pytest-dev/pytest/issues/11068>`_: Fixed the ``--last-failed`` whole-file skipping functionality ("skipped N files") for :ref:`non-python test files <non-python tests>`.
2589
2590
2591 - `#11104 <https://github.com/pytest-dev/pytest/issues/11104>`_: Fixed a regression in pytest 7.3.2 which caused to :confval:`testpaths` to be considered for loading initial conftests,
2592 even when it was not utilized (e.g. when explicit paths were given on the command line).
2593 Now the ``testpaths`` are only considered when they are in use.
2594
2595
2596 - `#1904 <https://github.com/pytest-dev/pytest/issues/1904>`_: Fixed traceback entries hidden with ``__tracebackhide__ = True`` still being shown for chained exceptions (parts after "... the above exception ..." message).
2597
2598
2599 - `#7781 <https://github.com/pytest-dev/pytest/issues/7781>`_: Fix writing non-encodable text to log file when using ``--debug``.
2600
2601
2602
2603 Improved Documentation
2604 ----------------------
2605
2606 - `#9146 <https://github.com/pytest-dev/pytest/issues/9146>`_: Improved documentation for :func:`caplog.set_level() <pytest.LogCaptureFixture.set_level>`.
2607
2608
2609
2610 Trivial/Internal Changes
2611 ------------------------
2612
2613 - `#11031 <https://github.com/pytest-dev/pytest/issues/11031>`_: Enhanced the CLI flag for ``-c`` to now include ``--config-file`` to make it clear that this flag applies to the usage of a custom config file.
2614
2615
2616 pytest 7.3.2 (2023-06-10)
2617 =========================
2618
2619 Bug Fixes
2620 ---------
2621
2622 - `#10169 <https://github.com/pytest-dev/pytest/issues/10169>`_: Fix bug where very long option names could cause pytest to break with ``OSError: [Errno 36] File name too long`` on some systems.
2623
2624
2625 - `#10894 <https://github.com/pytest-dev/pytest/issues/10894>`_: Support for Python 3.12 (beta at the time of writing).
2626
2627
2628 - `#10987 <https://github.com/pytest-dev/pytest/issues/10987>`_: :confval:`testpaths` is now honored to load root ``conftests``.
2629
2630
2631 - `#10999 <https://github.com/pytest-dev/pytest/issues/10999>`_: The `monkeypatch` `setitem`/`delitem` type annotations now allow `TypedDict` arguments.
2632
2633
2634 - `#11028 <https://github.com/pytest-dev/pytest/issues/11028>`_: Fixed bug in assertion rewriting where a variable assigned with the walrus operator could not be used later in a function call.
2635
2636
2637 - `#11054 <https://github.com/pytest-dev/pytest/issues/11054>`_: Fixed ``--last-failed``'s "(skipped N files)" functionality for files inside of packages (directories with `__init__.py` files).
2638
2639
2640 pytest 7.3.1 (2023-04-14)
2641 =========================
2642
2643 Improvements
2644 ------------
2645
2646 - `#10875 <https://github.com/pytest-dev/pytest/issues/10875>`_: Python 3.12 support: fixed ``RuntimeError: TestResult has no addDuration method`` when running ``unittest`` tests.
2647
2648
2649 - `#10890 <https://github.com/pytest-dev/pytest/issues/10890>`_: Python 3.12 support: fixed ``shutil.rmtree(onerror=...)`` deprecation warning when using :fixture:`tmp_path`.
2650
2651
2652
2653 Bug Fixes
2654 ---------
2655
2656 - `#10896 <https://github.com/pytest-dev/pytest/issues/10896>`_: Fixed performance regression related to :fixture:`tmp_path` and the new :confval:`tmp_path_retention_policy` option.
2657
2658
2659 - `#10903 <https://github.com/pytest-dev/pytest/issues/10903>`_: Fix crash ``INTERNALERROR IndexError: list index out of range`` which happens when displaying an exception where all entries are hidden.
2660 This reverts the change "Correctly handle ``__tracebackhide__`` for chained exceptions." introduced in version 7.3.0.
2661
2662
2663 pytest 7.3.0 (2023-04-08)
2664 =========================
2665
2666 Features
2667 --------
2668
2669 - `#10525 <https://github.com/pytest-dev/pytest/issues/10525>`_: Test methods decorated with ``@classmethod`` can now be discovered as tests, following the same rules as normal methods. This fills the gap that static methods were discoverable as tests but not class methods.
2670
2671
2672 - `#10755 <https://github.com/pytest-dev/pytest/issues/10755>`_: :confval:`console_output_style` now supports ``progress-even-when-capture-no`` to force the use of the progress output even when capture is disabled. This is useful in large test suites where capture may have significant performance impact.
2673
2674
2675 - `#7431 <https://github.com/pytest-dev/pytest/issues/7431>`_: ``--log-disable`` CLI option added to disable individual loggers.
2676
2677
2678 - `#8141 <https://github.com/pytest-dev/pytest/issues/8141>`_: Added :confval:`tmp_path_retention_count` and :confval:`tmp_path_retention_policy` configuration options to control how directories created by the :fixture:`tmp_path` fixture are kept.
2679
2680
2681
2682 Improvements
2683 ------------
2684
2685 - `#10226 <https://github.com/pytest-dev/pytest/issues/10226>`_: If multiple errors are raised in teardown, we now re-raise an ``ExceptionGroup`` of them instead of discarding all but the last.
2686
2687
2688 - `#10658 <https://github.com/pytest-dev/pytest/issues/10658>`_: Allow ``-p`` arguments to include spaces (eg: ``-p no:logging`` instead of
2689 ``-pno:logging``). Mostly useful in the ``addopts`` section of the configuration
2690 file.
2691
2692
2693 - `#10710 <https://github.com/pytest-dev/pytest/issues/10710>`_: Added ``start`` and ``stop`` timestamps to ``TestReport`` objects.
2694
2695
2696 - `#10727 <https://github.com/pytest-dev/pytest/issues/10727>`_: Split the report header for ``rootdir``, ``config file`` and ``testpaths`` so each has its own line.
2697
2698
2699 - `#10840 <https://github.com/pytest-dev/pytest/issues/10840>`_: pytest should no longer crash on AST with pathological position attributes, for example testing AST produced by `Hylang <https://github.com/hylang/hy>__`.
2700
2701
2702 - `#6267 <https://github.com/pytest-dev/pytest/issues/6267>`_: The full output of a test is no longer truncated if the truncation message would be longer than
2703 the hidden text. The line number shown has also been fixed.
2704
2705
2706
2707 Bug Fixes
2708 ---------
2709
2710 - `#10743 <https://github.com/pytest-dev/pytest/issues/10743>`_: The assertion rewriting mechanism now works correctly when assertion expressions contain the walrus operator.
2711
2712
2713 - `#10765 <https://github.com/pytest-dev/pytest/issues/10765>`_: Fixed :fixture:`tmp_path` fixture always raising :class:`OSError` on ``emscripten`` platform due to missing :func:`os.getuid`.
2714
2715
2716 - `#1904 <https://github.com/pytest-dev/pytest/issues/1904>`_: Correctly handle ``__tracebackhide__`` for chained exceptions.
2717 NOTE: This change was reverted in version 7.3.1.
2718
2719
2720
2721 Improved Documentation
2722 ----------------------
2723
2724 - `#10782 <https://github.com/pytest-dev/pytest/issues/10782>`_: Fixed the minimal example in :ref:`goodpractices`: ``pip install -e .`` requires a ``version`` entry in ``pyproject.toml`` to run successfully.
2725
2726
2727
2728 Trivial/Internal Changes
2729 ------------------------
2730
2731 - `#10669 <https://github.com/pytest-dev/pytest/issues/10669>`_: pytest no longer directly depends on the `attrs <https://www.attrs.org/en/stable/>`__ package. While
2732 we at pytest all love the package dearly and would like to thank the ``attrs`` team for many years of cooperation and support,
2733 it makes sense for ``pytest`` to have as little external dependencies as possible, as this helps downstream projects.
2734 With that in mind, we have replaced the pytest's limited internal usage to use the standard library's ``dataclasses`` instead.
2735
2736 Nice diffs for ``attrs`` classes are still supported though.
2737
2738
2739 pytest 7.2.2 (2023-03-03)
2740 =========================
2741
2742 Bug Fixes
2743 ---------
2744
2745 - `#10533 <https://github.com/pytest-dev/pytest/issues/10533>`_: Fixed :func:`pytest.approx` handling of dictionaries containing one or more values of `0.0`.
2746
2747
2748 - `#10592 <https://github.com/pytest-dev/pytest/issues/10592>`_: Fixed crash if `--cache-show` and `--help` are passed at the same time.
2749
2750
2751 - `#10597 <https://github.com/pytest-dev/pytest/issues/10597>`_: Fixed bug where a fixture method named ``teardown`` would be called as part of ``nose`` teardown stage.
2752
2753
2754 - `#10626 <https://github.com/pytest-dev/pytest/issues/10626>`_: Fixed crash if ``--fixtures`` and ``--help`` are passed at the same time.
2755
2756
2757 - `#10660 <https://github.com/pytest-dev/pytest/issues/10660>`_: Fixed :py:func:`pytest.raises` to return a 'ContextManager' so that type-checkers could narrow
2758 :code:`pytest.raises(...) if ... else nullcontext()` down to 'ContextManager' rather than 'object'.
2759
2760
2761
2762 Improved Documentation
2763 ----------------------
2764
2765 - `#10690 <https://github.com/pytest-dev/pytest/issues/10690>`_: Added `CI` and `BUILD_NUMBER` environment variables to the documentation.
2766
2767
2768 - `#10721 <https://github.com/pytest-dev/pytest/issues/10721>`_: Fixed entry-points declaration in the documentation example using Hatch.
2769
2770
2771 - `#10753 <https://github.com/pytest-dev/pytest/issues/10753>`_: Changed wording of the module level skip to be very explicit
2772 about not collecting tests and not executing the rest of the module.
2773
2774
2775 pytest 7.2.1 (2023-01-13)
2776 =========================
2777
2778 Bug Fixes
2779 ---------
2780
2781 - `#10452 <https://github.com/pytest-dev/pytest/issues/10452>`_: Fix 'importlib.abc.TraversableResources' deprecation warning in Python 3.12.
2782
2783
2784 - `#10457 <https://github.com/pytest-dev/pytest/issues/10457>`_: If a test is skipped from inside a fixture, the test summary now shows the test location instead of the fixture location.
2785
2786
2787 - `#10506 <https://github.com/pytest-dev/pytest/issues/10506>`_: Fix bug where sometimes pytest would use the file system root directory as :ref:`rootdir <rootdir>` on Windows.
2788
2789
2790 - `#10607 <https://github.com/pytest-dev/pytest/issues/10607>`_: Fix a race condition when creating junitxml reports, which could occur when multiple instances of pytest execute in parallel.
2791
2792
2793 - `#10641 <https://github.com/pytest-dev/pytest/issues/10641>`_: Fix a race condition when creating or updating the stepwise plugin's cache, which could occur when multiple xdist worker nodes try to simultaneously update the stepwise plugin's cache.
2794
2795
2796 pytest 7.2.0 (2022-10-23)
2797 =========================
2798
2799 Deprecations
2800 ------------
2801
2802 - `#10012 <https://github.com/pytest-dev/pytest/issues/10012>`_: Update ``pytest.PytestUnhandledCoroutineWarning`` to a deprecation; it will raise an error in pytest 8.
2803
2804
2805 - `#10396 <https://github.com/pytest-dev/pytest/issues/10396>`_: pytest no longer depends on the ``py`` library. ``pytest`` provides a vendored copy of ``py.error`` and ``py.path`` modules but will use the ``py`` library if it is installed. If you need other ``py.*`` modules, continue to install the deprecated ``py`` library separately, otherwise it can usually be removed as a dependency.
2806
2807
2808 - `#4562 <https://github.com/pytest-dev/pytest/issues/4562>`_: Deprecate configuring hook specs/impls using attributes/marks.
2809
2810 Instead use :py:func:`pytest.hookimpl` and :py:func:`pytest.hookspec`.
2811 For more details, see the :ref:`docs <legacy-path-hooks-deprecated>`.
2812
2813
2814 - `#9886 <https://github.com/pytest-dev/pytest/issues/9886>`_: The functionality for running tests written for ``nose`` has been officially deprecated.
2815
2816 This includes:
2817
2818 * Plain ``setup`` and ``teardown`` functions and methods: this might catch users by surprise, as ``setup()`` and ``teardown()`` are not pytest idioms, but part of the ``nose`` support.
2819 * Setup/teardown using the `@with_setup <with-setup-nose>`_ decorator.
2820
2821 For more details, consult the :ref:`deprecation docs <nose-deprecation>`.
2822
2823 .. _`with-setup-nose`: https://nose.readthedocs.io/en/latest/testing_tools.html?highlight=with_setup#nose.tools.with_setup
2824
2825 - `#7337 <https://github.com/pytest-dev/pytest/issues/7337>`_: A deprecation warning is now emitted if a test function returns something other than `None`. This prevents a common mistake among beginners that expect that returning a `bool` (for example `return foo(a, b) == result`) would cause a test to pass or fail, instead of using `assert`. The plan is to make returning non-`None` from tests an error in the future.
2826
2827
2828 Features
2829 --------
2830
2831 - `#9897 <https://github.com/pytest-dev/pytest/issues/9897>`_: Added shell-style wildcard support to ``testpaths``.
2832
2833
2834
2835 Improvements
2836 ------------
2837
2838 - `#10218 <https://github.com/pytest-dev/pytest/issues/10218>`_: ``@pytest.mark.parametrize()`` (and similar functions) now accepts any ``Sequence[str]`` for the argument names,
2839 instead of just ``list[str]`` and ``tuple[str, ...]``.
2840
2841 (Note that ``str``, which is itself a ``Sequence[str]``, is still treated as a
2842 comma-delimited name list, as before).
2843
2844
2845 - `#10381 <https://github.com/pytest-dev/pytest/issues/10381>`_: The ``--no-showlocals`` flag has been added. This can be passed directly to tests to override ``--showlocals`` declared through ``addopts``.
2846
2847
2848 - `#3426 <https://github.com/pytest-dev/pytest/issues/3426>`_: Assertion failures with strings in NFC and NFD forms that normalize to the same string now have a dedicated error message detailing the issue, and their utf-8 representation is expressed instead.
2849
2850
2851 - `#8508 <https://github.com/pytest-dev/pytest/issues/8508>`_: Introduce multiline display for warning matching via :py:func:`pytest.warns` and
2852 enhance match comparison for :py:func:`pytest.ExceptionInfo.match` as returned by :py:func:`pytest.raises`.
2853
2854
2855 - `#8646 <https://github.com/pytest-dev/pytest/issues/8646>`_: Improve :py:func:`pytest.raises`. Previously passing an empty tuple would give a confusing
2856 error. We now raise immediately with a more helpful message.
2857
2858
2859 - `#9741 <https://github.com/pytest-dev/pytest/issues/9741>`_: On Python 3.11, use the standard library's :mod:`tomllib` to parse TOML.
2860
2861 `tomli` is no longer a dependency on Python 3.11.
2862
2863
2864 - `#9742 <https://github.com/pytest-dev/pytest/issues/9742>`_: Display assertion message without escaped newline characters with ``-vv``.
2865
2866
2867 - `#9823 <https://github.com/pytest-dev/pytest/issues/9823>`_: Improved error message that is shown when no collector is found for a given file.
2868
2869
2870 - `#9873 <https://github.com/pytest-dev/pytest/issues/9873>`_: Some coloring has been added to the short test summary.
2871
2872
2873 - `#9883 <https://github.com/pytest-dev/pytest/issues/9883>`_: Normalize the help description of all command-line options.
2874
2875
2876 - `#9920 <https://github.com/pytest-dev/pytest/issues/9920>`_: Display full crash messages in ``short test summary info``, when running in a CI environment.
2877
2878
2879 - `#9987 <https://github.com/pytest-dev/pytest/issues/9987>`_: Added support for hidden configuration file by allowing ``.pytest.ini`` as an alternative to ``pytest.ini``.
2880
2881
2882
2883 Bug Fixes
2884 ---------
2885
2886 - `#10150 <https://github.com/pytest-dev/pytest/issues/10150>`_: :data:`sys.stdin` now contains all expected methods of a file-like object when capture is enabled.
2887
2888
2889 - `#10382 <https://github.com/pytest-dev/pytest/issues/10382>`_: Do not break into pdb when ``raise unittest.SkipTest()`` appears top-level in a file.
2890
2891
2892 - `#7792 <https://github.com/pytest-dev/pytest/issues/7792>`_: Marks are now inherited according to the full MRO in test classes. Previously, if a test class inherited from two or more classes, only marks from the first super-class would apply.
2893
2894 When inheriting marks from super-classes, marks from the sub-classes are now ordered before marks from the super-classes, in MRO order. Previously it was the reverse.
2895
2896 When inheriting marks from super-classes, the `pytestmark` attribute of the sub-class now only contains the marks directly applied to it. Previously, it also contained marks from its super-classes. Please note that this attribute should not normally be accessed directly; use :func:`Node.iter_markers <_pytest.nodes.Node.iter_markers>` instead.
2897
2898
2899 - `#9159 <https://github.com/pytest-dev/pytest/issues/9159>`_: Showing inner exceptions by forcing native display in ``ExceptionGroups`` even when using display options other than ``--tb=native``. A temporary step before full implementation of pytest-native display for inner exceptions in ``ExceptionGroups``.
2900
2901
2902 - `#9877 <https://github.com/pytest-dev/pytest/issues/9877>`_: Ensure ``caplog.get_records(when)`` returns current/correct data after invoking ``caplog.clear()``.
2903
2904
2905
2906 Improved Documentation
2907 ----------------------
2908
2909 - `#10344 <https://github.com/pytest-dev/pytest/issues/10344>`_: Update information on writing plugins to use ``pyproject.toml`` instead of ``setup.py``.
2910
2911
2912 - `#9248 <https://github.com/pytest-dev/pytest/issues/9248>`_: The documentation is now built using Sphinx 5.x (up from 3.x previously).
2913
2914
2915 - `#9291 <https://github.com/pytest-dev/pytest/issues/9291>`_: Update documentation on how :func:`pytest.warns` affects :class:`DeprecationWarning`.
2916
2917
2918
2919 Trivial/Internal Changes
2920 ------------------------
2921
2922 - `#10313 <https://github.com/pytest-dev/pytest/issues/10313>`_: Made ``_pytest.doctest.DoctestItem`` export ``pytest.DoctestItem`` for
2923 type check and runtime purposes. Made `_pytest.doctest` use internal APIs
2924 to avoid circular imports.
2925
2926
2927 - `#9906 <https://github.com/pytest-dev/pytest/issues/9906>`_: Made ``_pytest.compat`` re-export ``importlib_metadata`` in the eyes of type checkers.
2928
2929
2930 - `#9910 <https://github.com/pytest-dev/pytest/issues/9910>`_: Fix default encoding warning (``EncodingWarning``) in ``cacheprovider``
2931
2932
2933 - `#9984 <https://github.com/pytest-dev/pytest/issues/9984>`_: Improve the error message when we attempt to access a fixture that has been
2934 torn down.
2935 Add an additional sentence to the docstring explaining when it's not a good
2936 idea to call ``getfixturevalue``.
2937
2938
2939 pytest 7.1.3 (2022-08-31)
2940 =========================
2941
2942 Bug Fixes
2943 ---------
2944
2945 - `#10060 <https://github.com/pytest-dev/pytest/issues/10060>`_: When running with ``--pdb``, ``TestCase.tearDown`` is no longer called for tests when the *class* has been skipped via ``unittest.skip`` or ``pytest.mark.skip``.
2946
2947
2948 - `#10190 <https://github.com/pytest-dev/pytest/issues/10190>`_: Invalid XML characters in setup or teardown error messages are now properly escaped for JUnit XML reports.
2949
2950
2951 - `#10230 <https://github.com/pytest-dev/pytest/issues/10230>`_: Ignore ``.py`` files created by ``pyproject.toml``-based editable builds introduced in `pip 21.3 <https://pip.pypa.io/en/stable/news/#v21-3>`__.
2952
2953
2954 - `#3396 <https://github.com/pytest-dev/pytest/issues/3396>`_: Doctests now respect the ``--import-mode`` flag.
2955
2956
2957 - `#9514 <https://github.com/pytest-dev/pytest/issues/9514>`_: Type-annotate ``FixtureRequest.param`` as ``Any`` as a stop gap measure until :issue:`8073` is fixed.
2958
2959
2960 - `#9791 <https://github.com/pytest-dev/pytest/issues/9791>`_: Fixed a path handling code in ``rewrite.py`` that seems to work fine, but was incorrect and fails in some systems.
2961
2962
2963 - `#9917 <https://github.com/pytest-dev/pytest/issues/9917>`_: Fixed string representation for :func:`pytest.approx` when used to compare tuples.
2964
2965
2966
2967 Improved Documentation
2968 ----------------------
2969
2970 - `#9937 <https://github.com/pytest-dev/pytest/issues/9937>`_: Explicit note that :fixture:`tmpdir` fixture is discouraged in favour of :fixture:`tmp_path`.
2971
2972
2973
2974 Trivial/Internal Changes
2975 ------------------------
2976
2977 - `#10114 <https://github.com/pytest-dev/pytest/issues/10114>`_: Replace `atomicwrites <https://github.com/untitaker/python-atomicwrites>`__ dependency on windows with `os.replace`.
2978
2979
2980 pytest 7.1.2 (2022-04-23)
2981 =========================
2982
2983 Bug Fixes
2984 ---------
2985
2986 - `#9726 <https://github.com/pytest-dev/pytest/issues/9726>`_: An unnecessary ``numpy`` import inside :func:`pytest.approx` was removed.
2987
2988
2989 - `#9820 <https://github.com/pytest-dev/pytest/issues/9820>`_: Fix comparison of ``dataclasses`` with ``InitVar``.
2990
2991
2992 - `#9869 <https://github.com/pytest-dev/pytest/issues/9869>`_: Increase ``stacklevel`` for the ``NODE_CTOR_FSPATH_ARG`` deprecation to point to the
2993 user's code, not pytest.
2994
2995
2996 - `#9871 <https://github.com/pytest-dev/pytest/issues/9871>`_: Fix a bizarre (and fortunately rare) bug where the `temp_path` fixture could raise
2997 an internal error while attempting to get the current user's username.
2998
2999
3000 pytest 7.1.1 (2022-03-17)
3001 =========================
3002
3003 Bug Fixes
3004 ---------
3005
3006 - `#9767 <https://github.com/pytest-dev/pytest/issues/9767>`_: Fixed a regression in pytest 7.1.0 where some conftest.py files outside of the source tree (e.g. in the `site-packages` directory) were not picked up.
3007
3008
3009 pytest 7.1.0 (2022-03-13)
3010 =========================
3011
3012 Breaking Changes
3013 ----------------
3014
3015 - `#8838 <https://github.com/pytest-dev/pytest/issues/8838>`_: As per our policy, the following features have been deprecated in the 6.X series and are now
3016 removed:
3017
3018 * ``pytest._fillfuncargs`` function.
3019
3020 * ``pytest_warning_captured`` hook - use ``pytest_warning_recorded`` instead.
3021
3022 * ``-k -foobar`` syntax - use ``-k 'not foobar'`` instead.
3023
3024 * ``-k foobar:`` syntax.
3025
3026 * ``pytest.collect`` module - import from ``pytest`` directly.
3027
3028 For more information consult
3029 `Deprecations and Removals <https://docs.pytest.org/en/latest/deprecations.html>`__ in the docs.
3030
3031
3032 - `#9437 <https://github.com/pytest-dev/pytest/issues/9437>`_: Dropped support for Python 3.6, which reached `end-of-life <https://devguide.python.org/#status-of-python-branches>`__ at 2021-12-23.
3033
3034
3035
3036 Improvements
3037 ------------
3038
3039 - `#5192 <https://github.com/pytest-dev/pytest/issues/5192>`_: Fixed test output for some data types where ``-v`` would show less information.
3040
3041 Also, when showing diffs for sequences, ``-q`` would produce full diffs instead of the expected diff.
3042
3043
3044 - `#9362 <https://github.com/pytest-dev/pytest/issues/9362>`_: pytest now avoids specialized assert formatting when it is detected that the default ``__eq__`` is overridden in ``attrs`` or ``dataclasses``.
3045
3046
3047 - `#9536 <https://github.com/pytest-dev/pytest/issues/9536>`_: When ``-vv`` is given on command line, show skipping and xfail reasons in full instead of truncating them to fit the terminal width.
3048
3049
3050 - `#9644 <https://github.com/pytest-dev/pytest/issues/9644>`_: More information about the location of resources that led Python to raise :class:`ResourceWarning` can now
3051 be obtained by enabling :mod:`tracemalloc`.
3052
3053 See :ref:`resource-warnings` for more information.
3054
3055
3056 - `#9678 <https://github.com/pytest-dev/pytest/issues/9678>`_: More types are now accepted in the ``ids`` argument to ``@pytest.mark.parametrize``.
3057 Previously only `str`, `float`, `int` and `bool` were accepted;
3058 now `bytes`, `complex`, `re.Pattern`, `Enum` and anything with a `__name__` are also accepted.
3059
3060
3061 - `#9692 <https://github.com/pytest-dev/pytest/issues/9692>`_: :func:`pytest.approx` now raises a :class:`TypeError` when given an unordered sequence (such as :class:`set`).
3062
3063 Note that this implies that custom classes which only implement ``__iter__`` and ``__len__`` are no longer supported as they don't guarantee order.
3064
3065
3066
3067 Bug Fixes
3068 ---------
3069
3070 - `#8242 <https://github.com/pytest-dev/pytest/issues/8242>`_: The deprecation of raising :class:`unittest.SkipTest` to skip collection of
3071 tests during the pytest collection phase is reverted - this is now a supported
3072 feature again.
3073
3074
3075 - `#9493 <https://github.com/pytest-dev/pytest/issues/9493>`_: Symbolic link components are no longer resolved in conftest paths.
3076 This means that if a conftest appears twice in collection tree, using symlinks, it will be executed twice.
3077 For example, given
3078
3079 tests/real/conftest.py
3080 tests/real/test_it.py
3081 tests/link -> tests/real
3082
3083 running ``pytest tests`` now imports the conftest twice, once as ``tests/real/conftest.py`` and once as ``tests/link/conftest.py``.
3084 This is a fix to match a similar change made to test collection itself in pytest 6.0 (see :pr:`6523` for details).
3085
3086
3087 - `#9626 <https://github.com/pytest-dev/pytest/issues/9626>`_: Fixed count of selected tests on terminal collection summary when there were errors or skipped modules.
3088
3089 If there were errors or skipped modules on collection, pytest would mistakenly subtract those from the selected count.
3090
3091
3092 - `#9645 <https://github.com/pytest-dev/pytest/issues/9645>`_: Fixed regression where ``--import-mode=importlib`` used together with :envvar:`PYTHONPATH` or :confval:`pythonpath` would cause import errors in test suites.
3093
3094
3095 - `#9708 <https://github.com/pytest-dev/pytest/issues/9708>`_: :fixture:`pytester` now requests a :fixture:`monkeypatch` fixture instead of creating one internally. This solves some issues with tests that involve pytest environment variables.
3096
3097
3098 - `#9730 <https://github.com/pytest-dev/pytest/issues/9730>`_: Malformed ``pyproject.toml`` files now produce a clearer error message.
3099
3100
3101 pytest 7.0.1 (2022-02-11)
3102 =========================
3103
3104 Bug Fixes
3105 ---------
3106
3107 - `#9608 <https://github.com/pytest-dev/pytest/issues/9608>`_: Fix invalid importing of ``importlib.readers`` in Python 3.9.
3108
3109
3110 - `#9610 <https://github.com/pytest-dev/pytest/issues/9610>`_: Restore `UnitTestFunction.obj` to return unbound rather than bound method.
3111 Fixes a crash during a failed teardown in unittest TestCases with non-default `__init__`.
3112 Regressed in pytest 7.0.0.
3113
3114
3115 - `#9636 <https://github.com/pytest-dev/pytest/issues/9636>`_: The ``pythonpath`` plugin was renamed to ``python_path``. This avoids a conflict with the ``pytest-pythonpath`` plugin.
3116
3117
3118 - `#9642 <https://github.com/pytest-dev/pytest/issues/9642>`_: Fix running tests by id with ``::`` in the parametrize portion.
3119
3120
3121 - `#9643 <https://github.com/pytest-dev/pytest/issues/9643>`_: Delay issuing a :class:`~pytest.PytestWarning` about diamond inheritance involving :class:`~pytest.Item` and
3122 :class:`~pytest.Collector` so it can be filtered using :ref:`standard warning filters <warnings>`.
3123
3124
3125 pytest 7.0.0 (2022-02-03)
3126 =========================
3127
3128 (**Please see the full set of changes for this release also in the 7.0.0rc1 notes below**)
3129
3130 Deprecations
3131 ------------
3132
3133 - `#9488 <https://github.com/pytest-dev/pytest/issues/9488>`_: If custom subclasses of nodes like :class:`pytest.Item` override the
3134 ``__init__`` method, they should take ``**kwargs``. See
3135 :ref:`uncooperative-constructors-deprecated` for details.
3136
3137 Note that a deprecation warning is only emitted when there is a conflict in the
3138 arguments pytest expected to pass. This deprecation was already part of pytest
3139 7.0.0rc1 but wasn't documented.
3140
3141
3142
3143 Bug Fixes
3144 ---------
3145
3146 - `#9355 <https://github.com/pytest-dev/pytest/issues/9355>`_: Fixed error message prints function decorators when using assert in Python 3.8 and above.
3147
3148
3149 - `#9396 <https://github.com/pytest-dev/pytest/issues/9396>`_: Ensure `pytest.Config.inifile` is available during the :hook:`pytest_cmdline_main` hook (regression during ``7.0.0rc1``).
3150
3151
3152
3153 Improved Documentation
3154 ----------------------
3155
3156 - `#9404 <https://github.com/pytest-dev/pytest/issues/9404>`_: Added extra documentation on alternatives to common misuses of `pytest.warns(None)` ahead of its deprecation.
3157
3158
3159 - `#9505 <https://github.com/pytest-dev/pytest/issues/9505>`_: Clarify where the configuration files are located. To avoid confusions documentation mentions
3160 that configuration file is located in the root of the repository.
3161
3162
3163
3164 Trivial/Internal Changes
3165 ------------------------
3166
3167 - `#9521 <https://github.com/pytest-dev/pytest/issues/9521>`_: Add test coverage to assertion rewrite path.
3168
3169
3170 pytest 7.0.0rc1 (2021-12-06)
3171 ============================
3172
3173 Breaking Changes
3174 ----------------
3175
3176 - `#7259 <https://github.com/pytest-dev/pytest/issues/7259>`_: The :ref:`Node.reportinfo() <non-python tests>` function first return value type has been expanded from `py.path.local | str` to `os.PathLike[str] | str`.
3177
3178 Most plugins which refer to `reportinfo()` only define it as part of a custom :class:`pytest.Item` implementation.
3179 Since `py.path.local` is an `os.PathLike[str]`, these plugins are unaffected.
3180
3181 Plugins and users which call `reportinfo()`, use the first return value and interact with it as a `py.path.local`, would need to adjust by calling `py.path.local(fspath)`.
3182 Although preferably, avoid the legacy `py.path.local` and use `pathlib.Path`, or use `item.location` or `item.path`, instead.
3183
3184 Note: pytest was not able to provide a deprecation period for this change.
3185
3186
3187 - `#8246 <https://github.com/pytest-dev/pytest/issues/8246>`_: ``--version`` now writes version information to ``stdout`` rather than ``stderr``.
3188
3189 - `#8592 <https://github.com/pytest-dev/pytest/issues/8592>`_: The ``pytest_cmdline_preparse`` hook has been removed following its deprecation. See :ref:`the deprecation note <cmdline-preparse-deprecated>` for more details.
3190
3191 - `#8733 <https://github.com/pytest-dev/pytest/issues/8733>`_: Drop a workaround for `pyreadline <https://github.com/pyreadline/pyreadline>`__ that made it work with ``--pdb``.
3192
3193 The workaround was introduced in `#1281 <https://github.com/pytest-dev/pytest/pull/1281>`__ in 2015, however since then
3194 `pyreadline seems to have gone unmaintained <https://github.com/pyreadline/pyreadline/issues/58>`__, is `generating
3195 warnings <https://github.com/pytest-dev/pytest/issues/8847>`__, and will stop working on Python 3.10.
3196
3197
3198 - `#9061 <https://github.com/pytest-dev/pytest/issues/9061>`_: Using :func:`pytest.approx` in a boolean context now raises an error hinting at the proper usage.
3199
3200 It is apparently common for users to mistakenly use ``pytest.approx`` like this:
3201
3202 .. code-block:: python
3203
3204 assert pytest.approx(actual, expected)
3205
3206 While the correct usage is:
3207
3208 .. code-block:: python
3209
3210 assert actual == pytest.approx(expected)
3211
3212 The new error message helps catch those mistakes.
3213
3214
3215 - `#9277 <https://github.com/pytest-dev/pytest/issues/9277>`_: The ``pytest.Instance`` collector type has been removed.
3216 Importing ``pytest.Instance`` or ``_pytest.python.Instance`` returns a dummy type and emits a deprecation warning.
3217 See :ref:`instance-collector-deprecation` for details.
3218
3219
3220 - `#9308 <https://github.com/pytest-dev/pytest/issues/9308>`_: **PytestRemovedIn7Warning deprecation warnings are now errors by default.**
3221
3222 Following our plan to remove deprecated features with as little disruption as
3223 possible, all warnings of type ``PytestRemovedIn7Warning`` now generate errors
3224 instead of warning messages by default.
3225
3226 **The affected features will be effectively removed in pytest 7.1**, so please consult the
3227 :ref:`deprecations` section in the docs for directions on how to update existing code.
3228
3229 In the pytest ``7.0.X`` series, it is possible to change the errors back into warnings as a
3230 stopgap measure by adding this to your ``pytest.ini`` file:
3231
3232 .. code-block:: ini
3233
3234 [pytest]
3235 filterwarnings =
3236 ignore::pytest.PytestRemovedIn7Warning
3237
3238 But this will stop working when pytest ``7.1`` is released.
3239
3240 **If you have concerns** about the removal of a specific feature, please add a
3241 comment to :issue:`9308`.
3242
3243
3244
3245 Deprecations
3246 ------------
3247
3248 - `#7259 <https://github.com/pytest-dev/pytest/issues/7259>`_: ``py.path.local`` arguments for hooks have been deprecated. See :ref:`the deprecation note <legacy-path-hooks-deprecated>` for full details.
3249
3250 ``py.path.local`` arguments to Node constructors have been deprecated. See :ref:`the deprecation note <node-ctor-fspath-deprecation>` for full details.
3251
3252 .. note::
3253 The name of the :class:`~_pytest.nodes.Node` arguments and attributes (the
3254 new attribute being ``path``) is **the opposite** of the situation for hooks
3255 (the old argument being ``path``).
3256
3257 This is an unfortunate artifact due to historical reasons, which should be
3258 resolved in future versions as we slowly get rid of the :pypi:`py`
3259 dependency (see :issue:`9283` for a longer discussion).
3260
3261
3262 - `#7469 <https://github.com/pytest-dev/pytest/issues/7469>`_: Directly constructing the following classes is now deprecated:
3263
3264 - ``_pytest.mark.structures.Mark``
3265 - ``_pytest.mark.structures.MarkDecorator``
3266 - ``_pytest.mark.structures.MarkGenerator``
3267 - ``_pytest.python.Metafunc``
3268 - ``_pytest.runner.CallInfo``
3269 - ``_pytest._code.ExceptionInfo``
3270 - ``_pytest.config.argparsing.Parser``
3271 - ``_pytest.config.argparsing.OptionGroup``
3272 - ``_pytest.pytester.HookRecorder``
3273
3274 These constructors have always been considered private, but now issue a deprecation warning, which may become a hard error in pytest 8.
3275
3276
3277 - `#8242 <https://github.com/pytest-dev/pytest/issues/8242>`_: Raising :class:`unittest.SkipTest` to skip collection of tests during the
3278 pytest collection phase is deprecated. Use :func:`pytest.skip` instead.
3279
3280 Note: This deprecation only relates to using :class:`unittest.SkipTest` during test
3281 collection. You are probably not doing that. Ordinary usage of
3282 :class:`unittest.SkipTest` / :meth:`unittest.TestCase.skipTest` /
3283 :func:`unittest.skip` in unittest test cases is fully supported.
3284
3285 .. note:: This deprecation has been reverted in pytest 7.1.0.
3286
3287
3288 - `#8315 <https://github.com/pytest-dev/pytest/issues/8315>`_: Several behaviors of :meth:`Parser.addoption <pytest.Parser.addoption>` are now
3289 scheduled for removal in pytest 8 (deprecated since pytest 2.4.0):
3290
3291 - ``parser.addoption(..., help=".. %default ..")`` - use ``%(default)s`` instead.
3292 - ``parser.addoption(..., type="int/string/float/complex")`` - use ``type=int`` etc. instead.
3293
3294
3295 - `#8447 <https://github.com/pytest-dev/pytest/issues/8447>`_: Defining a custom pytest node type which is both an :class:`~pytest.Item` and a :class:`~pytest.Collector` (e.g. :class:`~pytest.File`) now issues a warning.
3296 It was never sanely supported and triggers hard to debug errors.
3297
3298 See :ref:`the deprecation note <diamond-inheritance-deprecated>` for full details.
3299
3300
3301 - `#8592 <https://github.com/pytest-dev/pytest/issues/8592>`_: ``pytest_cmdline_preparse`` has been officially deprecated. It will be removed in a future release. Use :hook:`pytest_load_initial_conftests` instead.
3302
3303 See :ref:`the deprecation note <cmdline-preparse-deprecated>` for full details.
3304
3305
3306 - `#8645 <https://github.com/pytest-dev/pytest/issues/8645>`_: :func:`pytest.warns(None) <pytest.warns>` is now deprecated because many people used
3307 it to mean "this code does not emit warnings", but it actually had the effect of
3308 checking that the code emits at least one warning of any type - like ``pytest.warns()``
3309 or ``pytest.warns(Warning)``.
3310
3311
3312 - `#8948 <https://github.com/pytest-dev/pytest/issues/8948>`_: :func:`pytest.skip(msg=...) <pytest.skip>`, :func:`pytest.fail(msg=...) <pytest.fail>` and :func:`pytest.exit(msg=...) <pytest.exit>`
3313 signatures now accept a ``reason`` argument instead of ``msg``. Using ``msg`` still works, but is deprecated and will be removed in a future release.
3314
3315 This was changed for consistency with :func:`pytest.mark.skip <pytest.mark.skip>` and :func:`pytest.mark.xfail <pytest.mark.xfail>` which both accept
3316 ``reason`` as an argument.
3317
3318 - `#8174 <https://github.com/pytest-dev/pytest/issues/8174>`_: The following changes have been made to types reachable through :attr:`pytest.ExceptionInfo.traceback`:
3319
3320 - The ``path`` property of ``_pytest.code.Code`` returns ``Path`` instead of ``py.path.local``.
3321 - The ``path`` property of ``_pytest.code.TracebackEntry`` returns ``Path`` instead of ``py.path.local``.
3322
3323 There was no deprecation period for this change (sorry!).
3324
3325
3326 Features
3327 --------
3328
3329 - `#5196 <https://github.com/pytest-dev/pytest/issues/5196>`_: Tests are now ordered by definition order in more cases.
3330
3331 In a class hierarchy, tests from base classes are now consistently ordered before tests defined on their subclasses (reverse MRO order).
3332
3333
3334 - `#7132 <https://github.com/pytest-dev/pytest/issues/7132>`_: Added two environment variables :envvar:`PYTEST_THEME` and :envvar:`PYTEST_THEME_MODE` to let the users customize the pygments theme used.
3335
3336
3337 - `#7259 <https://github.com/pytest-dev/pytest/issues/7259>`_: Added :meth:`cache.mkdir() <pytest.Cache.mkdir>`, which is similar to the existing ``cache.makedir()``,
3338 but returns a :class:`pathlib.Path` instead of a legacy ``py.path.local``.
3339
3340 Added a ``paths`` type to :meth:`parser.addini() <pytest.Parser.addini>`,
3341 as in ``parser.addini("mypaths", "my paths", type="paths")``,
3342 which is similar to the existing ``pathlist``,
3343 but returns a list of :class:`pathlib.Path` instead of legacy ``py.path.local``.
3344
3345
3346 - `#7469 <https://github.com/pytest-dev/pytest/issues/7469>`_: The types of objects used in pytest's API are now exported so they may be used in type annotations.
3347
3348 The newly-exported types are:
3349
3350 - ``pytest.Config`` for :class:`Config <pytest.Config>`.
3351 - ``pytest.Mark`` for :class:`marks <pytest.Mark>`.
3352 - ``pytest.MarkDecorator`` for :class:`mark decorators <pytest.MarkDecorator>`.
3353 - ``pytest.MarkGenerator`` for the :class:`pytest.mark <pytest.MarkGenerator>` singleton.
3354 - ``pytest.Metafunc`` for the :class:`metafunc <pytest.MarkGenerator>` argument to the :hook:`pytest_generate_tests` hook.
3355 - ``pytest.CallInfo`` for the :class:`CallInfo <pytest.CallInfo>` type passed to various hooks.
3356 - ``pytest.PytestPluginManager`` for :class:`PytestPluginManager <pytest.PytestPluginManager>`.
3357 - ``pytest.ExceptionInfo`` for the :class:`ExceptionInfo <pytest.ExceptionInfo>` type returned from :func:`pytest.raises` and passed to various hooks.
3358 - ``pytest.Parser`` for the :class:`Parser <pytest.Parser>` type passed to the :hook:`pytest_addoption` hook.
3359 - ``pytest.OptionGroup`` for the :class:`OptionGroup <pytest.OptionGroup>` type returned from the :func:`parser.addgroup <pytest.Parser.getgroup>` method.
3360 - ``pytest.HookRecorder`` for the :class:`HookRecorder <pytest.HookRecorder>` type returned from :class:`~pytest.Pytester`.
3361 - ``pytest.RecordedHookCall`` for the :class:`RecordedHookCall <pytest.HookRecorder>` type returned from :class:`~pytest.HookRecorder`.
3362 - ``pytest.RunResult`` for the :class:`RunResult <pytest.RunResult>` type returned from :class:`~pytest.Pytester`.
3363 - ``pytest.LineMatcher`` for the :class:`LineMatcher <pytest.LineMatcher>` type used in :class:`~pytest.RunResult` and others.
3364 - ``pytest.TestReport`` for the :class:`TestReport <pytest.TestReport>` type used in various hooks.
3365 - ``pytest.CollectReport`` for the :class:`CollectReport <pytest.CollectReport>` type used in various hooks.
3366
3367 Constructing most of them directly is not supported; they are only meant for use in type annotations.
3368 Doing so will emit a deprecation warning, and may become a hard-error in pytest 8.0.
3369
3370 Subclassing them is also not supported. This is not currently enforced at runtime, but is detected by type-checkers such as mypy.
3371
3372
3373 - `#7856 <https://github.com/pytest-dev/pytest/issues/7856>`_: :ref:`--import-mode=importlib <import-modes>` now works with features that
3374 depend on modules being on :py:data:`sys.modules`, such as :mod:`pickle` and :mod:`dataclasses`.
3375
3376
3377 - `#8144 <https://github.com/pytest-dev/pytest/issues/8144>`_: The following hooks now receive an additional ``pathlib.Path`` argument, equivalent to an existing ``py.path.local`` argument:
3378
3379 - :hook:`pytest_ignore_collect` - The ``collection_path`` parameter (equivalent to existing ``path`` parameter).
3380 - :hook:`pytest_collect_file` - The ``file_path`` parameter (equivalent to existing ``path`` parameter).
3381 - :hook:`pytest_pycollect_makemodule` - The ``module_path`` parameter (equivalent to existing ``path`` parameter).
3382 - :hook:`pytest_report_header` - The ``start_path`` parameter (equivalent to existing ``startdir`` parameter).
3383 - :hook:`pytest_report_collectionfinish` - The ``start_path`` parameter (equivalent to existing ``startdir`` parameter).
3384
3385 .. note::
3386 The name of the :class:`~_pytest.nodes.Node` arguments and attributes (the
3387 new attribute being ``path``) is **the opposite** of the situation for hooks
3388 (the old argument being ``path``).
3389
3390 This is an unfortunate artifact due to historical reasons, which should be
3391 resolved in future versions as we slowly get rid of the :pypi:`py`
3392 dependency (see :issue:`9283` for a longer discussion).
3393
3394
3395 - `#8251 <https://github.com/pytest-dev/pytest/issues/8251>`_: Implement ``Node.path`` as a ``pathlib.Path``. Both the old ``fspath`` and this new attribute gets set no matter whether ``path`` or ``fspath`` (deprecated) is passed to the constructor. It is a replacement for the ``fspath`` attribute (which represents the same path as ``py.path.local``). While ``fspath`` is not deprecated yet
3396 due to the ongoing migration of methods like :meth:`~pytest.Item.reportinfo`, we expect to deprecate it in a future release.
3397
3398 .. note::
3399 The name of the :class:`~_pytest.nodes.Node` arguments and attributes (the
3400 new attribute being ``path``) is **the opposite** of the situation for hooks
3401 (the old argument being ``path``).
3402
3403 This is an unfortunate artifact due to historical reasons, which should be
3404 resolved in future versions as we slowly get rid of the :pypi:`py`
3405 dependency (see :issue:`9283` for a longer discussion).
3406
3407
3408 - `#8421 <https://github.com/pytest-dev/pytest/issues/8421>`_: :func:`pytest.approx` now works on :class:`~decimal.Decimal` within mappings/dicts and sequences/lists.
3409
3410
3411 - `#8606 <https://github.com/pytest-dev/pytest/issues/8606>`_: pytest invocations with ``--fixtures-per-test`` and ``--fixtures`` have been enriched with:
3412
3413 - Fixture location path printed with the fixture name.
3414 - First section of the fixture's docstring printed under the fixture name.
3415 - Whole of fixture's docstring printed under the fixture name using ``--verbose`` option.
3416
3417
3418 - `#8761 <https://github.com/pytest-dev/pytest/issues/8761>`_: New :ref:`version-tuple` attribute, which makes it simpler for users to do something depending on the pytest version (such as declaring hooks which are introduced in later versions).
3419
3420
3421 - `#8789 <https://github.com/pytest-dev/pytest/issues/8789>`_: Switch TOML parser from ``toml`` to ``tomli`` for TOML v1.0.0 support in ``pyproject.toml``.
3422
3423
3424 - `#8920 <https://github.com/pytest-dev/pytest/issues/8920>`_: Added :class:`pytest.Stash`, a facility for plugins to store their data on :class:`~pytest.Config` and :class:`~_pytest.nodes.Node`\s in a type-safe and conflict-free manner.
3425 See :ref:`plugin-stash` for details.
3426
3427
3428 - `#8953 <https://github.com/pytest-dev/pytest/issues/8953>`_: :class:`~pytest.RunResult` method :meth:`~pytest.RunResult.assert_outcomes` now accepts a
3429 ``warnings`` argument to assert the total number of warnings captured.
3430
3431
3432 - `#8954 <https://github.com/pytest-dev/pytest/issues/8954>`_: ``--debug`` flag now accepts a :class:`str` file to route debug logs into, remains defaulted to `pytestdebug.log`.
3433
3434
3435 - `#9023 <https://github.com/pytest-dev/pytest/issues/9023>`_: Full diffs are now always shown for equality assertions of iterables when
3436 `CI` or ``BUILD_NUMBER`` is found in the environment, even when ``-v`` isn't
3437 used.
3438
3439
3440 - `#9113 <https://github.com/pytest-dev/pytest/issues/9113>`_: :class:`~pytest.RunResult` method :meth:`~pytest.RunResult.assert_outcomes` now accepts a
3441 ``deselected`` argument to assert the total number of deselected tests.
3442
3443
3444 - `#9114 <https://github.com/pytest-dev/pytest/issues/9114>`_: Added :confval:`pythonpath` setting that adds listed paths to :data:`sys.path` for the duration of the test session. If you currently use the pytest-pythonpath or pytest-srcpaths plugins, you should be able to replace them with built-in `pythonpath` setting.
3445
3446
3447
3448 Improvements
3449 ------------
3450
3451 - `#7480 <https://github.com/pytest-dev/pytest/issues/7480>`_: A deprecation scheduled to be removed in a major version X (e.g. pytest 7, 8, 9, ...) now uses warning category `PytestRemovedInXWarning`,
3452 a subclass of :class:`~pytest.PytestDeprecationWarning`,
3453 instead of :class:`~pytest.PytestDeprecationWarning` directly.
3454
3455 See :ref:`backwards-compatibility` for more details.
3456
3457
3458 - `#7864 <https://github.com/pytest-dev/pytest/issues/7864>`_: Improved error messages when parsing warning filters.
3459
3460 Previously pytest would show an internal traceback, which besides being ugly sometimes would hide the cause
3461 of the problem (for example an ``ImportError`` while importing a specific warning type).
3462
3463
3464 - `#8335 <https://github.com/pytest-dev/pytest/issues/8335>`_: Improved :func:`pytest.approx` assertion messages for sequences of numbers.
3465
3466 The assertion messages now dumps a table with the index and the error of each diff.
3467 Example::
3468
3469 > assert [1, 2, 3, 4] == pytest.approx([1, 3, 3, 5])
3470 E assert comparison failed for 2 values:
3471 E Index | Obtained | Expected
3472 E 1 | 2 | 3 +- 3.0e-06
3473 E 3 | 4 | 5 +- 5.0e-06
3474
3475
3476 - `#8403 <https://github.com/pytest-dev/pytest/issues/8403>`_: By default, pytest will truncate long strings in assert errors so they don't clutter the output too much,
3477 currently at ``240`` characters by default.
3478
3479 However, in some cases the longer output helps, or is even crucial, to diagnose a failure. Using ``-v`` will
3480 now increase the truncation threshold to ``2400`` characters, and ``-vv`` or higher will disable truncation entirely.
3481
3482
3483 - `#8509 <https://github.com/pytest-dev/pytest/issues/8509>`_: Fixed issue where :meth:`unittest.TestCase.setUpClass` is not called when a test has `/` in its name since pytest 6.2.0.
3484
3485 This refers to the path part in pytest node IDs, e.g. ``TestClass::test_it`` in the node ID ``tests/test_file.py::TestClass::test_it``.
3486
3487 Now, instead of assuming that the test name does not contain ``/``, it is assumed that test path does not contain ``::``. We plan to hopefully make both of these work in the future.
3488
3489
3490 - `#8803 <https://github.com/pytest-dev/pytest/issues/8803>`_: It is now possible to add colors to custom log levels on cli log.
3491
3492 By using ``add_color_level`` from a :hook:`pytest_configure` hook, colors can be added::
3493
3494 logging_plugin = config.pluginmanager.get_plugin('logging-plugin')
3495 logging_plugin.log_cli_handler.formatter.add_color_level(logging.INFO, 'cyan')
3496 logging_plugin.log_cli_handler.formatter.add_color_level(logging.SPAM, 'blue')
3497
3498 See :ref:`log_colors` for more information.
3499
3500
3501 - `#8822 <https://github.com/pytest-dev/pytest/issues/8822>`_: When showing fixture paths in `--fixtures` or `--fixtures-by-test`, fixtures coming from pytest itself now display an elided path, rather than the full path to the file in the `site-packages` directory.
3502
3503
3504 - `#8898 <https://github.com/pytest-dev/pytest/issues/8898>`_: Complex numbers are now treated like floats and integers when generating parameterization IDs.
3505
3506
3507 - `#9062 <https://github.com/pytest-dev/pytest/issues/9062>`_: ``--stepwise-skip`` now implicitly enables ``--stepwise`` and can be used on its own.
3508
3509
3510 - `#9205 <https://github.com/pytest-dev/pytest/issues/9205>`_: :meth:`pytest.Cache.set` now preserves key order when saving dicts.
3511
3512
3513
3514 Bug Fixes
3515 ---------
3516
3517 - `#7124 <https://github.com/pytest-dev/pytest/issues/7124>`_: Fixed an issue where ``__main__.py`` would raise an ``ImportError`` when ``--doctest-modules`` was provided.
3518
3519
3520 - `#8061 <https://github.com/pytest-dev/pytest/issues/8061>`_: Fixed failing ``staticmethod`` test cases if they are inherited from a parent test class.
3521
3522
3523 - `#8192 <https://github.com/pytest-dev/pytest/issues/8192>`_: ``testdir.makefile`` now silently accepts values which don't start with ``.`` to maintain backward compatibility with older pytest versions.
3524
3525 ``pytester.makefile`` now issues a clearer error if the ``.`` is missing in the ``ext`` argument.
3526
3527
3528 - `#8258 <https://github.com/pytest-dev/pytest/issues/8258>`_: Fixed issue where pytest's ``faulthandler`` support would not dump traceback on crashes
3529 if the :mod:`faulthandler` module was already enabled during pytest startup (using
3530 ``python -X dev -m pytest`` for example).
3531
3532
3533 - `#8317 <https://github.com/pytest-dev/pytest/issues/8317>`_: Fixed an issue where illegal directory characters derived from ``getpass.getuser()`` raised an ``OSError``.
3534
3535
3536 - `#8367 <https://github.com/pytest-dev/pytest/issues/8367>`_: Fix ``Class.from_parent`` so it forwards extra keyword arguments to the constructor.
3537
3538
3539 - `#8377 <https://github.com/pytest-dev/pytest/issues/8377>`_: The test selection options ``pytest -k`` and ``pytest -m`` now support matching
3540 names containing forward slash (``/``) characters.
3541
3542
3543 - `#8384 <https://github.com/pytest-dev/pytest/issues/8384>`_: The ``@pytest.mark.skip`` decorator now correctly handles its arguments. When the ``reason`` argument is accidentally given both positional and as a keyword (e.g. because it was confused with ``skipif``), a ``TypeError`` now occurs. Before, such tests were silently skipped, and the positional argument ignored. Additionally, ``reason`` is now documented correctly as positional or keyword (rather than keyword-only).
3544
3545
3546 - `#8394 <https://github.com/pytest-dev/pytest/issues/8394>`_: Use private names for internal fixtures that handle classic setup/teardown so that they don't show up with the default ``--fixtures`` invocation (but they still show up with ``--fixtures -v``).
3547
3548
3549 - `#8456 <https://github.com/pytest-dev/pytest/issues/8456>`_: The :confval:`required_plugins` config option now works correctly when pre-releases of plugins are installed, rather than falsely claiming that those plugins aren't installed at all.
3550
3551
3552 - `#8464 <https://github.com/pytest-dev/pytest/issues/8464>`_: ``-c <config file>`` now also properly defines ``rootdir`` as the directory that contains ``<config file>``.
3553
3554
3555 - `#8503 <https://github.com/pytest-dev/pytest/issues/8503>`_: :meth:`pytest.MonkeyPatch.syspath_prepend` no longer fails when
3556 ``setuptools`` is not installed.
3557 It now only calls ``pkg_resources.fixup_namespace_packages`` if
3558 ``pkg_resources`` was previously imported, because it is not needed otherwise.
3559
3560
3561 - `#8548 <https://github.com/pytest-dev/pytest/issues/8548>`_: Introduce fix to handle precision width in ``log-cli-format`` in turn to fix output coloring for certain formats.
3562
3563
3564 - `#8796 <https://github.com/pytest-dev/pytest/issues/8796>`_: Fixed internal error when skipping doctests.
3565
3566
3567 - `#8983 <https://github.com/pytest-dev/pytest/issues/8983>`_: The test selection options ``pytest -k`` and ``pytest -m`` now support matching names containing backslash (`\\`) characters.
3568 Backslashes are treated literally, not as escape characters (the values being matched against are already escaped).
3569
3570
3571 - `#8990 <https://github.com/pytest-dev/pytest/issues/8990>`_: Fix `pytest -vv` crashing with an internal exception `AttributeError: 'str' object has no attribute 'relative_to'` in some cases.
3572
3573
3574 - `#9077 <https://github.com/pytest-dev/pytest/issues/9077>`_: Fixed confusing error message when ``request.fspath`` / ``request.path`` was accessed from a session-scoped fixture.
3575
3576
3577 - `#9131 <https://github.com/pytest-dev/pytest/issues/9131>`_: Fixed the URL used by ``--pastebin`` to use `bpa.st <http://bpa.st>`__.
3578
3579
3580 - `#9163 <https://github.com/pytest-dev/pytest/issues/9163>`_: The end line number and end column offset are now properly set for rewritten assert statements.
3581
3582
3583 - `#9169 <https://github.com/pytest-dev/pytest/issues/9169>`_: Support for the ``files`` API from ``importlib.resources`` within rewritten files.
3584
3585
3586 - `#9272 <https://github.com/pytest-dev/pytest/issues/9272>`_: The nose compatibility module-level fixtures `setup()` and `teardown()` are now only called once per module, instead of for each test function.
3587 They are now called even if object-level `setup`/`teardown` is defined.
3588
3589
3590
3591 Improved Documentation
3592 ----------------------
3593
3594 - `#4320 <https://github.com/pytest-dev/pytest/issues/4320>`_: Improved docs for `pytester.copy_example`.
3595
3596
3597 - `#5105 <https://github.com/pytest-dev/pytest/issues/5105>`_: Add automatically generated :ref:`plugin-list`. The list is updated on a periodic schedule.
3598
3599
3600 - `#8337 <https://github.com/pytest-dev/pytest/issues/8337>`_: Recommend `numpy.testing <https://numpy.org/doc/stable/reference/routines.testing.html>`__ module on :func:`pytest.approx` documentation.
3601
3602
3603 - `#8655 <https://github.com/pytest-dev/pytest/issues/8655>`_: Help text for ``--pdbcls`` more accurately reflects the option's behavior.
3604
3605
3606 - `#9210 <https://github.com/pytest-dev/pytest/issues/9210>`_: Remove incorrect docs about ``confcutdir`` being a configuration option: it can only be set through the ``--confcutdir`` command-line option.
3607
3608
3609 - `#9242 <https://github.com/pytest-dev/pytest/issues/9242>`_: Upgrade readthedocs configuration to use a `newer Ubuntu version <https://blog.readthedocs.com/new-build-specification/>`__` with better unicode support for PDF docs.
3610
3611
3612 - `#9341 <https://github.com/pytest-dev/pytest/issues/9341>`_: Various methods commonly used for :ref:`non-python tests` are now correctly documented in the reference docs. They were undocumented previously.
3613
3614
3615
3616 Trivial/Internal Changes
3617 ------------------------
3618
3619 - `#8133 <https://github.com/pytest-dev/pytest/issues/8133>`_: Migrate to ``setuptools_scm`` 6.x to use ``SETUPTOOLS_SCM_PRETEND_VERSION_FOR_PYTEST`` for more robust release tooling.
3620
3621
3622 - `#8174 <https://github.com/pytest-dev/pytest/issues/8174>`_: The following changes have been made to internal pytest types/functions:
3623
3624 - The ``_pytest.code.getfslineno()`` function returns ``Path`` instead of ``py.path.local``.
3625 - The ``_pytest.python.path_matches_patterns()`` function takes ``Path`` instead of ``py.path.local``.
3626 - The ``_pytest._code.Traceback.cut()`` function accepts any ``os.PathLike[str]``, not just ``py.path.local``.
3627
3628
3629 - `#8248 <https://github.com/pytest-dev/pytest/issues/8248>`_: Internal Restructure: let ``python.PyObjMixin`` inherit from ``nodes.Node`` to carry over typing information.
3630
3631
3632 - `#8432 <https://github.com/pytest-dev/pytest/issues/8432>`_: Improve error message when :func:`pytest.skip` is used at module level without passing `allow_module_level=True`.
3633
3634
3635 - `#8818 <https://github.com/pytest-dev/pytest/issues/8818>`_: Ensure ``regendoc`` opts out of ``TOX_ENV`` cachedir selection to ensure independent example test runs.
3636
3637
3638 - `#8913 <https://github.com/pytest-dev/pytest/issues/8913>`_: The private ``CallSpec2._arg2scopenum`` attribute has been removed after an internal refactoring.
3639
3640
3641 - `#8967 <https://github.com/pytest-dev/pytest/issues/8967>`_: :hook:`pytest_assertion_pass` is no longer considered experimental and
3642 future changes to it will be considered more carefully.
3643
3644
3645 - `#9202 <https://github.com/pytest-dev/pytest/issues/9202>`_: Add github action to upload coverage report to codecov instead of bash uploader.
3646
3647
3648 - `#9225 <https://github.com/pytest-dev/pytest/issues/9225>`_: Changed the command used to create sdist and wheel artifacts: using the build package instead of setup.py.
3649
3650
3651 - `#9351 <https://github.com/pytest-dev/pytest/issues/9351>`_: Correct minor typos in doc/en/example/special.rst.
3652
3653
3654 pytest 6.2.5 (2021-08-29)
3655 =========================
3656
3657
3658 Trivial/Internal Changes
3659 ------------------------
3660
3661 - :issue:`8494`: Python 3.10 is now supported.
3662
3663
3664 - :issue:`9040`: Enable compatibility with ``pluggy 1.0`` or later.
3665
3666
3667 pytest 6.2.4 (2021-05-04)
3668 =========================
3669
3670 Bug Fixes
3671 ---------
3672
3673 - :issue:`8539`: Fixed assertion rewriting on Python 3.10.
3674
3675
3676 pytest 6.2.3 (2021-04-03)
3677 =========================
3678
3679 Bug Fixes
3680 ---------
3681
3682 - :issue:`8414`: pytest used to create directories under ``/tmp`` with world-readable
3683 permissions. This means that any user in the system was able to read
3684 information written by tests in temporary directories (such as those created by
3685 the ``tmp_path``/``tmpdir`` fixture). Now the directories are created with
3686 private permissions.
3687
3688 pytest used to silently use a preexisting ``/tmp/pytest-of-<username>`` directory,
3689 even if owned by another user. This means another user could pre-create such a
3690 directory and gain control of another user's temporary directory. Now such a
3691 condition results in an error.
3692
3693
3694 pytest 6.2.2 (2021-01-25)
3695 =========================
3696
3697 Bug Fixes
3698 ---------
3699
3700 - :issue:`8152`: Fixed "(<Skipped instance>)" being shown as a skip reason in the verbose test summary line when the reason is empty.
3701
3702
3703 - :issue:`8249`: Fix the ``faulthandler`` plugin for occasions when running with ``twisted.logger`` and using ``pytest --capture=no``.
3704
3705
3706 pytest 6.2.1 (2020-12-15)
3707 =========================
3708
3709 Bug Fixes
3710 ---------
3711
3712 - :issue:`7678`: Fixed bug where ``ImportPathMismatchError`` would be raised for files compiled in
3713 the host and loaded later from an UNC mounted path (Windows).
3714
3715
3716 - :issue:`8132`: Fixed regression in ``approx``: in 6.2.0 ``approx`` no longer raises
3717 ``TypeError`` when dealing with non-numeric types, falling back to normal comparison.
3718 Before 6.2.0, array types like tf.DeviceArray fell through to the scalar case,
3719 and happened to compare correctly to a scalar if they had only one element.
3720 After 6.2.0, these types began failing, because they inherited neither from
3721 standard Python number hierarchy nor from ``numpy.ndarray``.
3722
3723 ``approx`` now converts arguments to ``numpy.ndarray`` if they expose the array
3724 protocol and are not scalars. This treats array-like objects like numpy arrays,
3725 regardless of size.
3726
3727
3728 pytest 6.2.0 (2020-12-12)
3729 =========================
3730
3731 Breaking Changes
3732 ----------------
3733
3734 - :issue:`7808`: pytest now supports python3.6+ only.
3735
3736
3737
3738 Deprecations
3739 ------------
3740
3741 - :issue:`7469`: Directly constructing/calling the following classes/functions is now deprecated:
3742
3743 - ``_pytest.cacheprovider.Cache``
3744 - ``_pytest.cacheprovider.Cache.for_config()``
3745 - ``_pytest.cacheprovider.Cache.clear_cache()``
3746 - ``_pytest.cacheprovider.Cache.cache_dir_from_config()``
3747 - ``_pytest.capture.CaptureFixture``
3748 - ``_pytest.fixtures.FixtureRequest``
3749 - ``_pytest.fixtures.SubRequest``
3750 - ``_pytest.logging.LogCaptureFixture``
3751 - ``_pytest.pytester.Pytester``
3752 - ``_pytest.pytester.Testdir``
3753 - ``_pytest.recwarn.WarningsRecorder``
3754 - ``_pytest.recwarn.WarningsChecker``
3755 - ``_pytest.tmpdir.TempPathFactory``
3756 - ``_pytest.tmpdir.TempdirFactory``
3757
3758 These have always been considered private, but now issue a deprecation warning, which may become a hard error in pytest 8.0.0.
3759
3760
3761 - :issue:`7530`: The ``--strict`` command-line option has been deprecated, use ``--strict-markers`` instead.
3762
3763 We have plans to maybe in the future to reintroduce ``--strict`` and make it an encompassing flag for all strictness
3764 related options (``--strict-markers`` and ``--strict-config`` at the moment, more might be introduced in the future).
3765
3766
3767 - :issue:`7988`: The ``@pytest.yield_fixture`` decorator/function is now deprecated. Use :func:`pytest.fixture` instead.
3768
3769 ``yield_fixture`` has been an alias for ``fixture`` for a very long time, so can be search/replaced safely.
3770
3771
3772
3773 Features
3774 --------
3775
3776 - :issue:`5299`: pytest now warns about unraisable exceptions and unhandled thread exceptions that occur in tests on Python>=3.8.
3777 See :ref:`unraisable` for more information.
3778
3779
3780 - :issue:`7425`: New :fixture:`pytester` fixture, which is identical to :fixture:`testdir` but its methods return :class:`pathlib.Path` when appropriate instead of ``py.path.local``.
3781
3782 This is part of the movement to use :class:`pathlib.Path` objects internally, in order to remove the dependency to ``py`` in the future.
3783
3784 Internally, the old ``pytest.Testdir`` is now a thin wrapper around :class:`~pytest.Pytester`, preserving the old interface.
3785
3786
3787 - :issue:`7695`: A new hook was added, `pytest_markeval_namespace` which should return a dictionary.
3788 This dictionary will be used to augment the "global" variables available to evaluate skipif/xfail/xpass markers.
3789
3790 Pseudo example
3791
3792 ``conftest.py``:
3793
3794 .. code-block:: python
3795
3796 def pytest_markeval_namespace():
3797 return {"color": "red"}
3798
3799 ``test_func.py``:
3800
3801 .. code-block:: python
3802
3803 @pytest.mark.skipif("color == 'blue'", reason="Color is not red")
3804 def test_func():
3805 assert False
3806
3807
3808 - :issue:`8006`: It is now possible to construct a :class:`~pytest.MonkeyPatch` object directly as ``pytest.MonkeyPatch()``,
3809 in cases when the :fixture:`monkeypatch` fixture cannot be used. Previously some users imported it
3810 from the private `_pytest.monkeypatch.MonkeyPatch` namespace.
3811
3812 Additionally, :meth:`MonkeyPatch.context <pytest.MonkeyPatch.context>` is now a classmethod,
3813 and can be used as ``with MonkeyPatch.context() as mp: ...``. This is the recommended way to use
3814 ``MonkeyPatch`` directly, since unlike the ``monkeypatch`` fixture, an instance created directly
3815 is not ``undo()``-ed automatically.
3816
3817
3818
3819 Improvements
3820 ------------
3821
3822 - :issue:`1265`: Added an ``__str__`` implementation to the :class:`~pytest.LineMatcher` class which is returned from ``pytester.run_pytest().stdout`` and similar. It returns the entire output, like the existing ``str()`` method.
3823
3824
3825 - :issue:`2044`: Verbose mode now shows the reason that a test was skipped in the test's terminal line after the "SKIPPED", "XFAIL" or "XPASS".
3826
3827
3828 - :issue:`7469` The types of builtin pytest fixtures are now exported so they may be used in type annotations of test functions.
3829 The newly-exported types are:
3830
3831 - ``pytest.FixtureRequest`` for the :fixture:`request` fixture.
3832 - ``pytest.Cache`` for the :fixture:`cache` fixture.
3833 - ``pytest.CaptureFixture[str]`` for the :fixture:`capfd` and :fixture:`capsys` fixtures.
3834 - ``pytest.CaptureFixture[bytes]`` for the :fixture:`capfdbinary` and :fixture:`capsysbinary` fixtures.
3835 - ``pytest.LogCaptureFixture`` for the :fixture:`caplog` fixture.
3836 - ``pytest.Pytester`` for the :fixture:`pytester` fixture.
3837 - ``pytest.Testdir`` for the :fixture:`testdir` fixture.
3838 - ``pytest.TempdirFactory`` for the :fixture:`tmpdir_factory` fixture.
3839 - ``pytest.TempPathFactory`` for the :fixture:`tmp_path_factory` fixture.
3840 - ``pytest.MonkeyPatch`` for the :fixture:`monkeypatch` fixture.
3841 - ``pytest.WarningsRecorder`` for the :fixture:`recwarn` fixture.
3842
3843 Constructing them is not supported (except for `MonkeyPatch`); they are only meant for use in type annotations.
3844 Doing so will emit a deprecation warning, and may become a hard-error in pytest 8.0.
3845
3846 Subclassing them is also not supported. This is not currently enforced at runtime, but is detected by type-checkers such as mypy.
3847
3848
3849 - :issue:`7527`: When a comparison between :func:`namedtuple <collections.namedtuple>` instances of the same type fails, pytest now shows the differing field names (possibly nested) instead of their indexes.
3850
3851
3852 - :issue:`7615`: :meth:`Node.warn <_pytest.nodes.Node.warn>` now permits any subclass of :class:`Warning`, not just :class:`PytestWarning <pytest.PytestWarning>`.
3853
3854
3855 - :issue:`7701`: Improved reporting when using ``--collected-only``. It will now show the number of collected tests in the summary stats.
3856
3857
3858 - :issue:`7710`: Use strict equality comparison for non-numeric types in :func:`pytest.approx` instead of
3859 raising :class:`TypeError`.
3860
3861 This was the undocumented behavior before 3.7, but is now officially a supported feature.
3862
3863
3864 - :issue:`7938`: New ``--sw-skip`` argument which is a shorthand for ``--stepwise-skip``.
3865
3866
3867 - :issue:`8023`: Added ``'node_modules'`` to default value for :confval:`norecursedirs`.
3868
3869
3870 - :issue:`8032`: :meth:`doClassCleanups <unittest.TestCase.doClassCleanups>` (introduced in :mod:`unittest` in Python and 3.8) is now called appropriately.
3871
3872
3873
3874 Bug Fixes
3875 ---------
3876
3877 - :issue:`4824`: Fixed quadratic behavior and improved performance of collection of items using autouse fixtures and xunit fixtures.
3878
3879
3880 - :issue:`7758`: Fixed an issue where some files in packages are getting lost from ``--lf`` even though they contain tests that failed. Regressed in pytest 5.4.0.
3881
3882
3883 - :issue:`7911`: Directories created by by :fixture:`tmp_path` and :fixture:`tmpdir` are now considered stale after 3 days without modification (previous value was 3 hours) to avoid deleting directories still in use in long running test suites.
3884
3885
3886 - :issue:`7913`: Fixed a crash or hang in :meth:`pytester.spawn <pytest.Pytester.spawn>` when the :mod:`readline` module is involved.
3887
3888
3889 - :issue:`7951`: Fixed handling of recursive symlinks when collecting tests.
3890
3891
3892 - :issue:`7981`: Fixed symlinked directories not being followed during collection. Regressed in pytest 6.1.0.
3893
3894
3895 - :issue:`8016`: Fixed only one doctest being collected when using ``pytest --doctest-modules path/to/an/__init__.py``.
3896
3897
3898
3899 Improved Documentation
3900 ----------------------
3901
3902 - :issue:`7429`: Add more information and use cases about skipping doctests.
3903
3904
3905 - :issue:`7780`: Classes which should not be inherited from are now marked ``final class`` in the API reference.
3906
3907
3908 - :issue:`7872`: ``_pytest.config.argparsing.Parser.addini()`` accepts explicit ``None`` and ``"string"``.
3909
3910
3911 - :issue:`7878`: In pull request section, ask to commit after editing changelog and authors file.
3912
3913
3914
3915 Trivial/Internal Changes
3916 ------------------------
3917
3918 - :issue:`7802`: The ``attrs`` dependency requirement is now >=19.2.0 instead of >=17.4.0.
3919
3920
3921 - :issue:`8014`: `.pyc` files created by pytest's assertion rewriting now conform to the newer :pep:`552` format on Python>=3.7.
3922 (These files are internal and only interpreted by pytest itself.)
3923
3924
3925 pytest 6.1.2 (2020-10-28)
3926 =========================
3927
3928 Bug Fixes
3929 ---------
3930
3931 - :issue:`7758`: Fixed an issue where some files in packages are getting lost from ``--lf`` even though they contain tests that failed. Regressed in pytest 5.4.0.
3932
3933
3934 - :issue:`7911`: Directories created by `tmpdir` are now considered stale after 3 days without modification (previous value was 3 hours) to avoid deleting directories still in use in long running test suites.
3935
3936
3937
3938 Improved Documentation
3939 ----------------------
3940
3941 - :issue:`7815`: Improve deprecation warning message for ``pytest._fillfuncargs()``.
3942
3943
3944 pytest 6.1.1 (2020-10-03)
3945 =========================
3946
3947 Bug Fixes
3948 ---------
3949
3950 - :issue:`7807`: Fixed regression in pytest 6.1.0 causing incorrect rootdir to be determined in some non-trivial cases where parent directories have config files as well.
3951
3952
3953 - :issue:`7814`: Fixed crash in header reporting when :confval:`testpaths` is used and contains absolute paths (regression in 6.1.0).
3954
3955
3956 pytest 6.1.0 (2020-09-26)
3957 =========================
3958
3959 Breaking Changes
3960 ----------------
3961
3962 - :issue:`5585`: As per our policy, the following features which have been deprecated in the 5.X series are now
3963 removed:
3964
3965 * The ``funcargnames`` read-only property of ``FixtureRequest``, ``Metafunc``, and ``Function`` classes. Use ``fixturenames`` attribute.
3966
3967 * ``@pytest.fixture`` no longer supports positional arguments, pass all arguments by keyword instead.
3968
3969 * Direct construction of ``Node`` subclasses now raise an error, use ``from_parent`` instead.
3970
3971 * The default value for ``junit_family`` has changed to ``xunit2``. If you require the old format, add ``junit_family=xunit1`` to your configuration file.
3972
3973 * The ``TerminalReporter`` no longer has a ``writer`` attribute. Plugin authors may use the public functions of the ``TerminalReporter`` instead of accessing the ``TerminalWriter`` object directly.
3974
3975 * The ``--result-log`` option has been removed. Users are recommended to use the `pytest-reportlog <https://github.com/pytest-dev/pytest-reportlog>`__ plugin instead.
3976
3977
3978 For more information consult :std:doc:`deprecations` in the docs.
3979
3980
3981
3982 Deprecations
3983 ------------
3984
3985 - :issue:`6981`: The ``pytest.collect`` module is deprecated: all its names can be imported from ``pytest`` directly.
3986
3987
3988 - :issue:`7097`: The ``pytest._fillfuncargs`` function is deprecated. This function was kept
3989 for backward compatibility with an older plugin.
3990
3991 It's functionality is not meant to be used directly, but if you must replace
3992 it, use `function._request._fillfixtures()` instead, though note this is not
3993 a public API and may break in the future.
3994
3995
3996 - :issue:`7210`: The special ``-k '-expr'`` syntax to ``-k`` is deprecated. Use ``-k 'not expr'``
3997 instead.
3998
3999 The special ``-k 'expr:'`` syntax to ``-k`` is deprecated. Please open an issue
4000 if you use this and want a replacement.
4001
4002
4003 - :issue:`7255`: The ``pytest_warning_captured`` hook is deprecated in favor
4004 of :hook:`pytest_warning_recorded`, and will be removed in a future version.
4005
4006
4007 - :issue:`7648`: The ``gethookproxy()`` and ``isinitpath()`` methods of ``FSCollector`` and ``Package`` are deprecated;
4008 use ``self.session.gethookproxy()`` and ``self.session.isinitpath()`` instead.
4009 This should work on all pytest versions.
4010
4011
4012
4013 Features
4014 --------
4015
4016 - :issue:`7667`: New ``--durations-min`` command-line flag controls the minimal duration for inclusion in the slowest list of tests shown by ``--durations``. Previously this was hard-coded to ``0.005s``.
4017
4018
4019
4020 Improvements
4021 ------------
4022
4023 - :issue:`6681`: Internal pytest warnings issued during the early stages of initialization are now properly handled and can filtered through :confval:`filterwarnings` or ``--pythonwarnings/-W``.
4024
4025 This also fixes a number of long standing issues: :issue:`2891`, :issue:`7620`, :issue:`7426`.
4026
4027
4028 - :issue:`7572`: When a plugin listed in ``required_plugins`` is missing or an unknown config key is used with ``--strict-config``, a simple error message is now shown instead of a stacktrace.
4029
4030
4031 - :issue:`7685`: Added two new attributes :attr:`rootpath <pytest.Config.rootpath>` and :attr:`inipath <pytest.Config.inipath>` to :class:`~pytest.Config`.
4032 These attributes are :class:`pathlib.Path` versions of the existing ``rootdir`` and ``inifile`` attributes,
4033 and should be preferred over them when possible.
4034
4035
4036 - :issue:`7780`: Public classes which are not designed to be inherited from are now marked :func:`@final <typing.final>`.
4037 Code which inherits from these classes will trigger a type-checking (e.g. mypy) error, but will still work in runtime.
4038 Currently the ``final`` designation does not appear in the API Reference but hopefully will in the future.
4039
4040
4041
4042 Bug Fixes
4043 ---------
4044
4045 - :issue:`1953`: Fixed error when overwriting a parametrized fixture, while also reusing the super fixture value.
4046
4047 .. code-block:: python
4048
4049 # conftest.py
4050 import pytest
4051
4052
4053 @pytest.fixture(params=[1, 2])
4054 def foo(request):
4055 return request.param
4056
4057
4058 # test_foo.py
4059 import pytest
4060
4061
4062 @pytest.fixture
4063 def foo(foo):
4064 return foo * 2
4065
4066
4067 - :issue:`4984`: Fixed an internal error crash with ``IndexError: list index out of range`` when
4068 collecting a module which starts with a decorated function, the decorator
4069 raises, and assertion rewriting is enabled.
4070
4071
4072 - :issue:`7591`: pylint shouldn't complain anymore about unimplemented abstract methods when inheriting from :ref:`File <non-python tests>`.
4073
4074
4075 - :issue:`7628`: Fixed test collection when a full path without a drive letter was passed to pytest on Windows (for example ``\projects\tests\test.py`` instead of ``c:\projects\tests\pytest.py``).
4076
4077
4078 - :issue:`7638`: Fix handling of command-line options that appear as paths but trigger an OS-level syntax error on Windows, such as the options used internally by ``pytest-xdist``.
4079
4080
4081 - :issue:`7742`: Fixed INTERNALERROR when accessing locals / globals with faulty ``exec``.
4082
4083
4084
4085 Improved Documentation
4086 ----------------------
4087
4088 - :issue:`1477`: Removed faq.rst and its reference in contents.rst.
4089
4090
4091
4092 Trivial/Internal Changes
4093 ------------------------
4094
4095 - :issue:`7536`: The internal ``junitxml`` plugin has rewritten to use ``xml.etree.ElementTree``.
4096 The order of attributes in XML elements might differ. Some unneeded escaping is
4097 no longer performed.
4098
4099
4100 - :issue:`7587`: The dependency on the ``more-itertools`` package has been removed.
4101
4102
4103 - :issue:`7631`: The result type of :meth:`capfd.readouterr() <pytest.CaptureFixture.readouterr>` (and similar) is no longer a namedtuple,
4104 but should behave like one in all respects. This was done for technical reasons.
4105
4106
4107 - :issue:`7671`: When collecting tests, pytest finds test classes and functions by examining the
4108 attributes of python objects (modules, classes and instances). To speed up this
4109 process, pytest now ignores builtin attributes (like ``__class__``,
4110 ``__delattr__`` and ``__new__``) without consulting the :confval:`python_classes` and
4111 :confval:`python_functions` configuration options and without passing them to plugins
4112 using the :hook:`pytest_pycollect_makeitem` hook.
4113
4114
4115 pytest 6.0.2 (2020-09-04)
4116 =========================
4117
4118 Bug Fixes
4119 ---------
4120
4121 - :issue:`7148`: Fixed ``--log-cli`` potentially causing unrelated ``print`` output to be swallowed.
4122
4123
4124 - :issue:`7672`: Fixed log-capturing level restored incorrectly if ``caplog.set_level`` is called more than once.
4125
4126
4127 - :issue:`7686`: Fixed `NotSetType.token` being used as the parameter ID when the parametrization list is empty.
4128 Regressed in pytest 6.0.0.
4129
4130
4131 - :issue:`7707`: Fix internal error when handling some exceptions that contain multiple lines or the style uses multiple lines (``--tb=line`` for example).
4132
4133
4134 pytest 6.0.1 (2020-07-30)
4135 =========================
4136
4137 Bug Fixes
4138 ---------
4139
4140 - :issue:`7394`: Passing an empty ``help`` value to ``Parser.add_option`` is now accepted instead of crashing when running ``pytest --help``.
4141 Passing ``None`` raises a more informative ``TypeError``.
4142
4143
4144 - :issue:`7558`: Fix pylint ``not-callable`` lint on ``pytest.mark.parametrize()`` and the other builtin marks:
4145 ``skip``, ``skipif``, ``xfail``, ``usefixtures``, ``filterwarnings``.
4146
4147
4148 - :issue:`7559`: Fix regression in plugins using ``TestReport.longreprtext`` (such as ``pytest-html``) when ``TestReport.longrepr`` is not a string.
4149
4150
4151 - :issue:`7569`: Fix logging capture handler's level not reset on teardown after a call to ``caplog.set_level()``.
4152
4153
4154 pytest 6.0.0 (2020-07-28)
4155 =========================
4156
4157 (**Please see the full set of changes for this release also in the 6.0.0rc1 notes below**)
4158
4159 Breaking Changes
4160 ----------------
4161
4162 - :issue:`5584`: **PytestDeprecationWarning are now errors by default.**
4163
4164 Following our plan to remove deprecated features with as little disruption as
4165 possible, all warnings of type ``PytestDeprecationWarning`` now generate errors
4166 instead of warning messages.
4167
4168 **The affected features will be effectively removed in pytest 6.1**, so please consult the
4169 :std:doc:`deprecations` section in the docs for directions on how to update existing code.
4170
4171 In the pytest ``6.0.X`` series, it is possible to change the errors back into warnings as a
4172 stopgap measure by adding this to your ``pytest.ini`` file:
4173
4174 .. code-block:: ini
4175
4176 [pytest]
4177 filterwarnings =
4178 ignore::pytest.PytestDeprecationWarning
4179
4180 But this will stop working when pytest ``6.1`` is released.
4181
4182 **If you have concerns** about the removal of a specific feature, please add a
4183 comment to :issue:`5584`.
4184
4185
4186 - :issue:`7472`: The ``exec_()`` and ``is_true()`` methods of ``_pytest._code.Frame`` have been removed.
4187
4188
4189
4190 Features
4191 --------
4192
4193 - :issue:`7464`: Added support for :envvar:`NO_COLOR` and :envvar:`FORCE_COLOR` environment variables to control colored output.
4194
4195
4196
4197 Improvements
4198 ------------
4199
4200 - :issue:`7467`: ``--log-file`` CLI option and ``log_file`` ini marker now create subdirectories if needed.
4201
4202
4203 - :issue:`7489`: The :func:`pytest.raises` function has a clearer error message when ``match`` equals the obtained string but is not a regex match. In this case it is suggested to escape the regex.
4204
4205
4206
4207 Bug Fixes
4208 ---------
4209
4210 - :issue:`7392`: Fix the reported location of tests skipped with ``@pytest.mark.skip`` when ``--runxfail`` is used.
4211
4212
4213 - :issue:`7491`: :fixture:`tmpdir` and :fixture:`tmp_path` no longer raise an error if the lock to check for
4214 stale temporary directories is not accessible.
4215
4216
4217 - :issue:`7517`: Preserve line endings when captured via ``capfd``.
4218
4219
4220 - :issue:`7534`: Restored the previous formatting of ``TracebackEntry.__str__`` which was changed by accident.
4221
4222
4223
4224 Improved Documentation
4225 ----------------------
4226
4227 - :issue:`7422`: Clarified when the ``usefixtures`` mark can apply fixtures to test.
4228
4229
4230 - :issue:`7441`: Add a note about ``-q`` option used in getting started guide.
4231
4232
4233
4234 Trivial/Internal Changes
4235 ------------------------
4236
4237 - :issue:`7389`: Fixture scope ``package`` is no longer considered experimental.
4238
4239
4240 pytest 6.0.0rc1 (2020-07-08)
4241 ============================
4242
4243 Breaking Changes
4244 ----------------
4245
4246 - :issue:`1316`: ``TestReport.longrepr`` is now always an instance of ``ReprExceptionInfo``. Previously it was a ``str`` when a test failed with ``pytest.fail(..., pytrace=False)``.
4247
4248
4249 - :issue:`5965`: symlinks are no longer resolved during collection and matching `conftest.py` files with test file paths.
4250
4251 Resolving symlinks for the current directory and during collection was introduced as a bugfix in 3.9.0, but it actually is a new feature which had unfortunate consequences in Windows and surprising results in other platforms.
4252
4253 The team decided to step back on resolving symlinks at all, planning to review this in the future with a more solid solution (see discussion in
4254 :pr:`6523` for details).
4255
4256 This might break test suites which made use of this feature; the fix is to create a symlink
4257 for the entire test tree, and not only to partial files/tress as it was possible previously.
4258
4259
4260 - :issue:`6505`: ``Testdir.run().parseoutcomes()`` now always returns the parsed nouns in plural form.
4261
4262 Originally ``parseoutcomes()`` would always returns the nouns in plural form, but a change
4263 meant to improve the terminal summary by using singular form single items (``1 warning`` or ``1 error``)
4264 caused an unintended regression by changing the keys returned by ``parseoutcomes()``.
4265
4266 Now the API guarantees to always return the plural form, so calls like this:
4267
4268 .. code-block:: python
4269
4270 result = testdir.runpytest()
4271 result.assert_outcomes(error=1)
4272
4273 Need to be changed to:
4274
4275
4276 .. code-block:: python
4277
4278 result = testdir.runpytest()
4279 result.assert_outcomes(errors=1)
4280
4281
4282 - :issue:`6903`: The ``os.dup()`` function is now assumed to exist. We are not aware of any
4283 supported Python 3 implementations which do not provide it.
4284
4285
4286 - :issue:`7040`: ``-k`` no longer matches against the names of the directories outside the test session root.
4287
4288 Also, ``pytest.Package.name`` is now just the name of the directory containing the package's
4289 ``__init__.py`` file, instead of the full path. This is consistent with how the other nodes
4290 are named, and also one of the reasons why ``-k`` would match against any directory containing
4291 the test suite.
4292
4293
4294 - :issue:`7122`: Expressions given to the ``-m`` and ``-k`` options are no longer evaluated using Python's :func:`eval`.
4295 The format supports ``or``, ``and``, ``not``, parenthesis and general identifiers to match against.
4296 Python constants, keywords or other operators are no longer evaluated differently.
4297
4298
4299 - :issue:`7135`: Pytest now uses its own ``TerminalWriter`` class instead of using the one from the ``py`` library.
4300 Plugins generally access this class through ``TerminalReporter.writer``, ``TerminalReporter.write()``
4301 (and similar methods), or ``_pytest.config.create_terminal_writer()``.
4302
4303 The following breaking changes were made:
4304
4305 - Output (``write()`` method and others) no longer flush implicitly; the flushing behavior
4306 of the underlying file is respected. To flush explicitly (for example, if you
4307 want output to be shown before an end-of-line is printed), use ``write(flush=True)`` or
4308 ``terminal_writer.flush()``.
4309 - Explicit Windows console support was removed, delegated to the colorama library.
4310 - Support for writing ``bytes`` was removed.
4311 - The ``reline`` method and ``chars_on_current_line`` property were removed.
4312 - The ``stringio`` and ``encoding`` arguments was removed.
4313 - Support for passing a callable instead of a file was removed.
4314
4315
4316 - :issue:`7224`: The `item.catch_log_handler` and `item.catch_log_handlers` attributes, set by the
4317 logging plugin and never meant to be public, are no longer available.
4318
4319 The deprecated ``--no-print-logs`` option and ``log_print`` ini option are removed. Use ``--show-capture`` instead.
4320
4321
4322 - :issue:`7226`: Removed the unused ``args`` parameter from ``pytest.Function.__init__``.
4323
4324
4325 - :issue:`7418`: Removed the `pytest_doctest_prepare_content` hook specification. This hook
4326 hasn't been triggered by pytest for at least 10 years.
4327
4328
4329 - :issue:`7438`: Some changes were made to the internal ``_pytest._code.source``, listed here
4330 for the benefit of plugin authors who may be using it:
4331
4332 - The ``deindent`` argument to ``Source()`` has been removed, now it is always true.
4333 - Support for zero or multiple arguments to ``Source()`` has been removed.
4334 - Support for comparing ``Source`` with an ``str`` has been removed.
4335 - The methods ``Source.isparseable()`` and ``Source.putaround()`` have been removed.
4336 - The method ``Source.compile()`` and function ``_pytest._code.compile()`` have
4337 been removed; use plain ``compile()`` instead.
4338 - The function ``_pytest._code.source.getsource()`` has been removed; use
4339 ``Source()`` directly instead.
4340
4341
4342
4343 Deprecations
4344 ------------
4345
4346 - :issue:`7210`: The special ``-k '-expr'`` syntax to ``-k`` is deprecated. Use ``-k 'not expr'``
4347 instead.
4348
4349 The special ``-k 'expr:'`` syntax to ``-k`` is deprecated. Please open an issue
4350 if you use this and want a replacement.
4351
4352 - :issue:`4049`: ``pytest_warning_captured`` is deprecated in favor of the ``pytest_warning_recorded`` hook.
4353
4354
4355 Features
4356 --------
4357
4358 - :issue:`1556`: pytest now supports ``pyproject.toml`` files for configuration.
4359
4360 The configuration options is similar to the one available in other formats, but must be defined
4361 in a ``[tool.pytest.ini_options]`` table to be picked up by pytest:
4362
4363 .. code-block:: toml
4364
4365 # pyproject.toml
4366 [tool.pytest.ini_options]
4367 minversion = "6.0"
4368 addopts = "-ra -q"
4369 testpaths = [
4370 "tests",
4371 "integration",
4372 ]
4373
4374 More information can be found :ref:`in the docs <config file formats>`.
4375
4376
4377 - :issue:`3342`: pytest now includes inline type annotations and exposes them to user programs.
4378 Most of the user-facing API is covered, as well as internal code.
4379
4380 If you are running a type checker such as mypy on your tests, you may start
4381 noticing type errors indicating incorrect usage. If you run into an error that
4382 you believe to be incorrect, please let us know in an issue.
4383
4384 The types were developed against mypy version 0.780. Versions before 0.750
4385 are known not to work. We recommend using the latest version. Other type
4386 checkers may work as well, but they are not officially verified to work by
4387 pytest yet.
4388
4389
4390 - :issue:`4049`: Introduced a new hook named `pytest_warning_recorded` to convey information about warnings captured by the internal `pytest` warnings plugin.
4391
4392 This hook is meant to replace `pytest_warning_captured`, which is deprecated and will be removed in a future release.
4393
4394
4395 - :issue:`6471`: New command-line flags:
4396
4397 * `--no-header`: disables the initial header, including platform, version, and plugins.
4398 * `--no-summary`: disables the final test summary, including warnings.
4399
4400
4401 - :issue:`6856`: A warning is now shown when an unknown key is read from a config INI file.
4402
4403 The `--strict-config` flag has been added to treat these warnings as errors.
4404
4405
4406 - :issue:`6906`: Added `--code-highlight` command line option to enable/disable code highlighting in terminal output.
4407
4408
4409 - :issue:`7245`: New ``--import-mode=importlib`` option that uses :mod:`importlib` to import test modules.
4410
4411 Traditionally pytest used ``__import__`` while changing ``sys.path`` to import test modules (which
4412 also changes ``sys.modules`` as a side-effect), which works but has a number of drawbacks, like requiring test modules
4413 that don't live in packages to have unique names (as they need to reside under a unique name in ``sys.modules``).
4414
4415 ``--import-mode=importlib`` uses more fine-grained import mechanisms from ``importlib`` which don't
4416 require pytest to change ``sys.path`` or ``sys.modules`` at all, eliminating much of the drawbacks
4417 of the previous mode.
4418
4419 We intend to make ``--import-mode=importlib`` the default in future versions, so users are encouraged
4420 to try the new mode and provide feedback (both positive or negative) in issue :issue:`7245`.
4421
4422 You can read more about this option in :std:ref:`the documentation <import-modes>`.
4423
4424
4425 - :issue:`7305`: New ``required_plugins`` configuration option allows the user to specify a list of plugins, including version information, that are required for pytest to run. An error is raised if any required plugins are not found when running pytest.
4426
4427
4428 Improvements
4429 ------------
4430
4431 - :issue:`4375`: The ``pytest`` command now suppresses the ``BrokenPipeError`` error message that
4432 is printed to stderr when the output of ``pytest`` is piped and the pipe is
4433 closed by the piped-to program (common examples are ``less`` and ``head``).
4434
4435
4436 - :issue:`4391`: Improved precision of test durations measurement. ``CallInfo`` items now have a new ``<CallInfo>.duration`` attribute, created using ``time.perf_counter()``. This attribute is used to fill the ``<TestReport>.duration`` attribute, which is more accurate than the previous ``<CallInfo>.stop - <CallInfo>.start`` (as these are based on ``time.time()``).
4437
4438
4439 - :issue:`4675`: Rich comparison for dataclasses and `attrs`-classes is now recursive.
4440
4441
4442 - :issue:`6285`: Exposed the `pytest.FixtureLookupError` exception which is raised by `request.getfixturevalue()`
4443 (where `request` is a `FixtureRequest` fixture) when a fixture with the given name cannot be returned.
4444
4445
4446 - :issue:`6433`: If an error is encountered while formatting the message in a logging call, for
4447 example ``logging.warning("oh no!: %s: %s", "first")`` (a second argument is
4448 missing), pytest now propagates the error, likely causing the test to fail.
4449
4450 Previously, such a mistake would cause an error to be printed to stderr, which
4451 is not displayed by default for passing tests. This change makes the mistake
4452 visible during testing.
4453
4454 You may suppress this behavior temporarily or permanently by setting
4455 ``logging.raiseExceptions = False``.
4456
4457
4458 - :issue:`6817`: Explicit new-lines in help texts of command-line options are preserved, allowing plugins better control
4459 of the help displayed to users.
4460
4461
4462 - :issue:`6940`: When using the ``--duration`` option, the terminal message output is now more precise about the number and duration of hidden items.
4463
4464
4465 - :issue:`6991`: Collected files are displayed after any reports from hooks, e.g. the status from ``--lf``.
4466
4467
4468 - :issue:`7091`: When ``fd`` capturing is used, through ``--capture=fd`` or the ``capfd`` and
4469 ``capfdbinary`` fixtures, and the file descriptor (0, 1, 2) cannot be
4470 duplicated, FD capturing is still performed. Previously, direct writes to the
4471 file descriptors would fail or be lost in this case.
4472
4473
4474 - :issue:`7119`: Exit with an error if the ``--basetemp`` argument is empty, is the current working directory or is one of the parent directories.
4475 This is done to protect against accidental data loss, as any directory passed to this argument is cleared.
4476
4477
4478 - :issue:`7128`: `pytest --version` now displays just the pytest version, while `pytest --version --version` displays more verbose information including plugins. This is more consistent with how other tools show `--version`.
4479
4480
4481 - :issue:`7133`: :meth:`caplog.set_level() <pytest.LogCaptureFixture.set_level>` will now override any :confval:`log_level` set via the CLI or configuration file.
4482
4483
4484 - :issue:`7159`: :meth:`caplog.set_level() <pytest.LogCaptureFixture.set_level>` and :meth:`caplog.at_level() <pytest.LogCaptureFixture.at_level>` no longer affect
4485 the level of logs that are shown in the *Captured log report* report section.
4486
4487
4488 - :issue:`7348`: Improve recursive diff report for comparison asserts on dataclasses / attrs.
4489
4490
4491 - :issue:`7385`: ``--junitxml`` now includes the exception cause in the ``message`` XML attribute for failures during setup and teardown.
4492
4493 Previously:
4494
4495 .. code-block:: xml
4496
4497 <error message="test setup failure">
4498
4499 Now:
4500
4501 .. code-block:: xml
4502
4503 <error message="failed on setup with &quot;ValueError: Some error during setup&quot;">
4504
4505
4506
4507 Bug Fixes
4508 ---------
4509
4510 - :issue:`1120`: Fix issue where directories from :fixture:`tmpdir` are not removed properly when multiple instances of pytest are running in parallel.
4511
4512
4513 - :issue:`4583`: Prevent crashing and provide a user-friendly error when a marker expression (`-m`) invoking of :func:`eval` raises any exception.
4514
4515
4516 - :issue:`4677`: The path shown in the summary report for SKIPPED tests is now always relative. Previously it was sometimes absolute.
4517
4518
4519 - :issue:`5456`: Fix a possible race condition when trying to remove lock files used to control access to folders
4520 created by :fixture:`tmp_path` and :fixture:`tmpdir`.
4521
4522
4523 - :issue:`6240`: Fixes an issue where logging during collection step caused duplication of log
4524 messages to stderr.
4525
4526
4527 - :issue:`6428`: Paths appearing in error messages are now correct in case the current working directory has
4528 changed since the start of the session.
4529
4530
4531 - :issue:`6755`: Support deleting paths longer than 260 characters on windows created inside :fixture:`tmpdir`.
4532
4533
4534 - :issue:`6871`: Fix crash with captured output when using :fixture:`capsysbinary`.
4535
4536
4537 - :issue:`6909`: Revert the change introduced by :pr:`6330`, which required all arguments to ``@pytest.mark.parametrize`` to be explicitly defined in the function signature.
4538
4539 The intention of the original change was to remove what was expected to be an unintended/surprising behavior, but it turns out many people relied on it, so the restriction has been reverted.
4540
4541
4542 - :issue:`6910`: Fix crash when plugins return an unknown stats while using the ``--reportlog`` option.
4543
4544
4545 - :issue:`6924`: Ensure a ``unittest.IsolatedAsyncioTestCase`` is actually awaited.
4546
4547
4548 - :issue:`6925`: Fix `TerminalRepr` instances to be hashable again.
4549
4550
4551 - :issue:`6947`: Fix regression where functions registered with :meth:`unittest.TestCase.addCleanup` were not being called on test failures.
4552
4553
4554 - :issue:`6951`: Allow users to still set the deprecated ``TerminalReporter.writer`` attribute.
4555
4556
4557 - :issue:`6956`: Prevent pytest from printing `ConftestImportFailure` traceback to stdout.
4558
4559
4560 - :issue:`6991`: Fix regressions with `--lf` filtering too much since pytest 5.4.
4561
4562
4563 - :issue:`6992`: Revert "tmpdir: clean up indirection via config for factories" :issue:`6767` as it breaks pytest-xdist.
4564
4565
4566 - :issue:`7061`: When a yielding fixture fails to yield a value, report a test setup error instead of crashing.
4567
4568
4569 - :issue:`7076`: The path of file skipped by ``@pytest.mark.skip`` in the SKIPPED report is now relative to invocation directory. Previously it was relative to root directory.
4570
4571
4572 - :issue:`7110`: Fixed regression: ``asyncbase.TestCase`` tests are executed correctly again.
4573
4574
4575 - :issue:`7126`: ``--setup-show`` now doesn't raise an error when a bytes value is used as a ``parametrize``
4576 parameter when Python is called with the ``-bb`` flag.
4577
4578
4579 - :issue:`7143`: Fix :meth:`pytest.File.from_parent <_pytest.nodes.Node.from_parent>` so it forwards extra keyword arguments to the constructor.
4580
4581
4582 - :issue:`7145`: Classes with broken ``__getattribute__`` methods are displayed correctly during failures.
4583
4584
4585 - :issue:`7150`: Prevent hiding the underlying exception when ``ConfTestImportFailure`` is raised.
4586
4587
4588 - :issue:`7180`: Fix ``_is_setup_py`` for files encoded differently than locale.
4589
4590
4591 - :issue:`7215`: Fix regression where running with ``--pdb`` would call :meth:`unittest.TestCase.tearDown` for skipped tests.
4592
4593
4594 - :issue:`7253`: When using ``pytest.fixture`` on a function directly, as in ``pytest.fixture(func)``,
4595 if the ``autouse`` or ``params`` arguments are also passed, the function is no longer
4596 ignored, but is marked as a fixture.
4597
4598
4599 - :issue:`7360`: Fix possibly incorrect evaluation of string expressions passed to ``pytest.mark.skipif`` and ``pytest.mark.xfail``,
4600 in rare circumstances where the exact same string is used but refers to different global values.
4601
4602
4603 - :issue:`7383`: Fixed exception causes all over the codebase, i.e. use `raise new_exception from old_exception` when wrapping an exception.
4604
4605
4606
4607 Improved Documentation
4608 ----------------------
4609
4610 - :issue:`7202`: The development guide now links to the contributing section of the docs and `RELEASING.rst` on GitHub.
4611
4612
4613 - :issue:`7233`: Add a note about ``--strict`` and ``--strict-markers`` and the preference for the latter one.
4614
4615
4616 - :issue:`7345`: Explain indirect parametrization and markers for fixtures.
4617
4618
4619
4620 Trivial/Internal Changes
4621 ------------------------
4622
4623 - :issue:`7035`: The ``originalname`` attribute of ``_pytest.python.Function`` now defaults to ``name`` if not
4624 provided explicitly, and is always set.
4625
4626
4627 - :issue:`7264`: The dependency on the ``wcwidth`` package has been removed.
4628
4629
4630 - :issue:`7291`: Replaced ``py.iniconfig`` with :pypi:`iniconfig`.
4631
4632
4633 - :issue:`7295`: ``src/_pytest/config/__init__.py`` now uses the ``warnings`` module to report warnings instead of ``sys.stderr.write``.
4634
4635
4636 - :issue:`7356`: Remove last internal uses of deprecated *slave* term from old ``pytest-xdist``.
4637
4638
4639 - :issue:`7357`: ``py``>=1.8.2 is now required.
4640
4641
4642 pytest 5.4.3 (2020-06-02)
4643 =========================
4644
4645 Bug Fixes
4646 ---------
4647
4648 - :issue:`6428`: Paths appearing in error messages are now correct in case the current working directory has
4649 changed since the start of the session.
4650
4651
4652 - :issue:`6755`: Support deleting paths longer than 260 characters on windows created inside tmpdir.
4653
4654
4655 - :issue:`6956`: Prevent pytest from printing ConftestImportFailure traceback to stdout.
4656
4657
4658 - :issue:`7150`: Prevent hiding the underlying exception when ``ConfTestImportFailure`` is raised.
4659
4660
4661 - :issue:`7215`: Fix regression where running with ``--pdb`` would call the ``tearDown`` methods of ``unittest.TestCase``
4662 subclasses for skipped tests.
4663
4664
4665 pytest 5.4.2 (2020-05-08)
4666 =========================
4667
4668 Bug Fixes
4669 ---------
4670
4671 - :issue:`6871`: Fix crash with captured output when using the :fixture:`capsysbinary fixture <capsysbinary>`.
4672
4673
4674 - :issue:`6924`: Ensure a ``unittest.IsolatedAsyncioTestCase`` is actually awaited.
4675
4676
4677 - :issue:`6925`: Fix TerminalRepr instances to be hashable again.
4678
4679
4680 - :issue:`6947`: Fix regression where functions registered with ``TestCase.addCleanup`` were not being called on test failures.
4681
4682
4683 - :issue:`6951`: Allow users to still set the deprecated ``TerminalReporter.writer`` attribute.
4684
4685
4686 - :issue:`6992`: Revert "tmpdir: clean up indirection via config for factories" #6767 as it breaks pytest-xdist.
4687
4688
4689 - :issue:`7110`: Fixed regression: ``asyncbase.TestCase`` tests are executed correctly again.
4690
4691
4692 - :issue:`7143`: Fix ``File.from_parent`` so it forwards extra keyword arguments to the constructor.
4693
4694
4695 - :issue:`7145`: Classes with broken ``__getattribute__`` methods are displayed correctly during failures.
4696
4697
4698 - :issue:`7180`: Fix ``_is_setup_py`` for files encoded differently than locale.
4699
4700
4701 pytest 5.4.1 (2020-03-13)
4702 =========================
4703
4704 Bug Fixes
4705 ---------
4706
4707 - :issue:`6909`: Revert the change introduced by :pr:`6330`, which required all arguments to ``@pytest.mark.parametrize`` to be explicitly defined in the function signature.
4708
4709 The intention of the original change was to remove what was expected to be an unintended/surprising behavior, but it turns out many people relied on it, so the restriction has been reverted.
4710
4711
4712 - :issue:`6910`: Fix crash when plugins return an unknown stats while using the ``--reportlog`` option.
4713
4714
4715 pytest 5.4.0 (2020-03-12)
4716 =========================
4717
4718 Breaking Changes
4719 ----------------
4720
4721 - :issue:`6316`: Matching of ``-k EXPRESSION`` to test names is now case-insensitive.
4722
4723
4724 - :issue:`6443`: Plugins specified with ``-p`` are now loaded after internal plugins, which results in their hooks being called *before* the internal ones.
4725
4726 This makes the ``-p`` behavior consistent with ``PYTEST_PLUGINS``.
4727
4728
4729 - :issue:`6637`: Removed the long-deprecated ``pytest_itemstart`` hook.
4730
4731 This hook has been marked as deprecated and not been even called by pytest for over 10 years now.
4732
4733
4734 - :issue:`6673`: Reversed / fix meaning of "+/-" in error diffs. "-" means that something expected is missing in the result and "+" means that there are unexpected extras in the result.
4735
4736
4737 - :issue:`6737`: The ``cached_result`` attribute of ``FixtureDef`` is now set to ``None`` when
4738 the result is unavailable, instead of being deleted.
4739
4740 If your plugin performs checks like ``hasattr(fixturedef, 'cached_result')``,
4741 for example in a ``pytest_fixture_post_finalizer`` hook implementation, replace
4742 it with ``fixturedef.cached_result is not None``. If you ``del`` the attribute,
4743 set it to ``None`` instead.
4744
4745
4746
4747 Deprecations
4748 ------------
4749
4750 - :issue:`3238`: Option ``--no-print-logs`` is deprecated and meant to be removed in a future release. If you use ``--no-print-logs``, please try out ``--show-capture`` and
4751 provide feedback.
4752
4753 ``--show-capture`` command-line option was added in ``pytest 3.5.0`` and allows to specify how to
4754 display captured output when tests fail: ``no``, ``stdout``, ``stderr``, ``log`` or ``all`` (the default).
4755
4756
4757 - :issue:`571`: Deprecate the unused/broken `pytest_collect_directory` hook.
4758 It was misaligned since the removal of the ``Directory`` collector in 2010
4759 and incorrect/unusable as soon as collection was split from test execution.
4760
4761
4762 - :issue:`5975`: Deprecate using direct constructors for ``Nodes``.
4763
4764 Instead they are now constructed via ``Node.from_parent``.
4765
4766 This transitional mechanism enables us to untangle the very intensely
4767 entangled ``Node`` relationships by enforcing more controlled creation/configuration patterns.
4768
4769 As part of this change, session/config are already disallowed parameters and as we work on the details we might need disallow a few more as well.
4770
4771 Subclasses are expected to use `super().from_parent` if they intend to expand the creation of `Nodes`.
4772
4773
4774 - :issue:`6779`: The ``TerminalReporter.writer`` attribute has been deprecated and should no longer be used. This
4775 was inadvertently exposed as part of the public API of that plugin and ties it too much
4776 with ``py.io.TerminalWriter``.
4777
4778
4779
4780 Features
4781 --------
4782
4783 - :issue:`4597`: New :ref:`--capture=tee-sys <capture-method>` option to allow both live printing and capturing of test output.
4784
4785
4786 - :issue:`5712`: Now all arguments to ``@pytest.mark.parametrize`` need to be explicitly declared in the function signature or via ``indirect``.
4787 Previously it was possible to omit an argument if a fixture with the same name existed, which was just an accident of implementation and was not meant to be a part of the API.
4788
4789
4790 - :issue:`6454`: Changed default for `-r` to `fE`, which displays failures and errors in the :ref:`short test summary <pytest.detailed_failed_tests_usage>`. `-rN` can be used to disable it (the old behavior).
4791
4792
4793 - :issue:`6469`: New options have been added to the :confval:`junit_logging` option: ``log``, ``out-err``, and ``all``.
4794
4795
4796 - :issue:`6834`: Excess warning summaries are now collapsed per file to ensure readable display of warning summaries.
4797
4798
4799
4800 Improvements
4801 ------------
4802
4803 - :issue:`1857`: ``pytest.mark.parametrize`` accepts integers for ``ids`` again, converting it to strings.
4804
4805
4806 - :issue:`449`: Use "yellow" main color with any XPASSED tests.
4807
4808
4809 - :issue:`4639`: Revert "A warning is now issued when assertions are made for ``None``".
4810
4811 The warning proved to be less useful than initially expected and had quite a
4812 few false positive cases.
4813
4814
4815 - :issue:`5686`: ``tmpdir_factory.mktemp`` now fails when given absolute and non-normalized paths.
4816
4817
4818 - :issue:`5984`: The ``pytest_warning_captured`` hook now receives a ``location`` parameter with the code location that generated the warning.
4819
4820
4821 - :issue:`6213`: pytester: the ``testdir`` fixture respects environment settings from the ``monkeypatch`` fixture for inner runs.
4822
4823
4824 - :issue:`6247`: ``--fulltrace`` is honored with collection errors.
4825
4826
4827 - :issue:`6384`: Make `--showlocals` work also with `--tb=short`.
4828
4829
4830 - :issue:`6653`: Add support for matching lines consecutively with :class:`~pytest.LineMatcher`'s :func:`~pytest.LineMatcher.fnmatch_lines` and :func:`~pytest.LineMatcher.re_match_lines`.
4831
4832
4833 - :issue:`6658`: Code is now highlighted in tracebacks when ``pygments`` is installed.
4834
4835 Users are encouraged to install ``pygments`` into their environment and provide feedback, because
4836 the plan is to make ``pygments`` a regular dependency in the future.
4837
4838
4839 - :issue:`6795`: Import usage error message with invalid `-o` option.
4840
4841
4842 - :issue:`759`: ``pytest.mark.parametrize`` supports iterators and generators for ``ids``.
4843
4844
4845
4846 Bug Fixes
4847 ---------
4848
4849 - :issue:`310`: Add support for calling `pytest.xfail()` and `pytest.importorskip()` with doctests.
4850
4851
4852 - :issue:`3823`: ``--trace`` now works with unittests.
4853
4854
4855 - :issue:`4445`: Fixed some warning reports produced by pytest to point to the correct location of the warning in the user's code.
4856
4857
4858 - :issue:`5301`: Fix ``--last-failed`` to collect new tests from files with known failures.
4859
4860
4861 - :issue:`5928`: Report ``PytestUnknownMarkWarning`` at the level of the user's code, not ``pytest``'s.
4862
4863
4864 - :issue:`5991`: Fix interaction with ``--pdb`` and unittests: do not use unittest's ``TestCase.debug()``.
4865
4866
4867 - :issue:`6334`: Fix summary entries appearing twice when ``f/F`` and ``s/S`` report chars were used at the same time in the ``-r`` command-line option (for example ``-rFf``).
4868
4869 The upper case variants were never documented and the preferred form should be the lower case.
4870
4871
4872 - :issue:`6409`: Fallback to green (instead of yellow) for non-last items without previous passes with colored terminal progress indicator.
4873
4874
4875 - :issue:`6454`: `--disable-warnings` is honored with `-ra` and `-rA`.
4876
4877
4878 - :issue:`6497`: Fix bug in the comparison of request key with cached key in fixture.
4879
4880 A construct ``if key == cached_key:`` can fail either because ``==`` is explicitly disallowed, or for, e.g., NumPy arrays, where the result of ``a == b`` cannot generally be converted to :class:`bool`.
4881 The implemented fix replaces `==` with ``is``.
4882
4883
4884 - :issue:`6557`: Make capture output streams ``.write()`` method return the same return value from original streams.
4885
4886
4887 - :issue:`6566`: Fix ``EncodedFile.writelines`` to call the underlying buffer's ``writelines`` method.
4888
4889
4890 - :issue:`6575`: Fix internal crash when ``faulthandler`` starts initialized
4891 (for example with ``PYTHONFAULTHANDLER=1`` environment variable set) and ``faulthandler_timeout`` defined
4892 in the configuration file.
4893
4894
4895 - :issue:`6597`: Fix node ids which contain a parametrized empty-string variable.
4896
4897
4898 - :issue:`6646`: Assertion rewriting hooks are (re)stored for the current item, which fixes them being still used after e.g. pytester's ``testdir.runpytest`` etc.
4899
4900
4901 - :issue:`6660`: :py:func:`pytest.exit` is handled when emitted from the :hook:`pytest_sessionfinish` hook. This includes quitting from a debugger.
4902
4903
4904 - :issue:`6752`: When :py:func:`pytest.raises` is used as a function (as opposed to a context manager),
4905 a `match` keyword argument is now passed through to the tested function. Previously
4906 it was swallowed and ignored (regression in pytest 5.1.0).
4907
4908
4909 - :issue:`6801`: Do not display empty lines in between traceback for unexpected exceptions with doctests.
4910
4911
4912 - :issue:`6802`: The :fixture:`testdir fixture <testdir>` works within doctests now.
4913
4914
4915
4916 Improved Documentation
4917 ----------------------
4918
4919 - :issue:`6696`: Add list of fixtures to start of fixture chapter.
4920
4921
4922 - :issue:`6742`: Expand first sentence on fixtures into a paragraph.
4923
4924
4925
4926 Trivial/Internal Changes
4927 ------------------------
4928
4929 - :issue:`6404`: Remove usage of ``parser`` module, deprecated in Python 3.9.
4930
4931
4932 pytest 5.3.5 (2020-01-29)
4933 =========================
4934
4935 Bug Fixes
4936 ---------
4937
4938 - :issue:`6517`: Fix regression in pytest 5.3.4 causing an INTERNALERROR due to a wrong assertion.
4939
4940
4941 pytest 5.3.4 (2020-01-20)
4942 =========================
4943
4944 Bug Fixes
4945 ---------
4946
4947 - :issue:`6496`: Revert :issue:`6436`: unfortunately this change has caused a number of regressions in many suites,
4948 so the team decided to revert this change and make a new release while we continue to look for a solution.
4949
4950
4951 pytest 5.3.3 (2020-01-16)
4952 =========================
4953
4954 Bug Fixes
4955 ---------
4956
4957 - :issue:`2780`: Captured output during teardown is shown with ``-rP``.
4958
4959
4960 - :issue:`5971`: Fix a ``pytest-xdist`` crash when dealing with exceptions raised in subprocesses created by the
4961 ``multiprocessing`` module.
4962
4963
4964 - :issue:`6436`: :class:`~pytest.FixtureDef` objects now properly register their finalizers with autouse and
4965 parameterized fixtures that execute before them in the fixture stack so they are torn
4966 down at the right times, and in the right order.
4967
4968
4969 - :issue:`6532`: Fix parsing of outcomes containing multiple errors with ``testdir`` results (regression in 5.3.0).
4970
4971
4972
4973 Trivial/Internal Changes
4974 ------------------------
4975
4976 - :issue:`6350`: Optimized automatic renaming of test parameter IDs.
4977
4978
4979 pytest 5.3.2 (2019-12-13)
4980 =========================
4981
4982 Improvements
4983 ------------
4984
4985 - :issue:`4639`: Revert "A warning is now issued when assertions are made for ``None``".
4986
4987 The warning proved to be less useful than initially expected and had quite a
4988 few false positive cases.
4989
4990
4991
4992 Bug Fixes
4993 ---------
4994
4995 - :issue:`5430`: junitxml: Logs for failed test are now passed to junit report in case the test fails during call phase.
4996
4997
4998 - :issue:`6290`: The supporting files in the ``.pytest_cache`` directory are kept with ``--cache-clear``, which only clears cached values now.
4999
5000
5001 - :issue:`6301`: Fix assertion rewriting for egg-based distributions and ``editable`` installs (``pip install --editable``).
5002
5003
5004 pytest 5.3.1 (2019-11-25)
5005 =========================
5006
5007 Improvements
5008 ------------
5009
5010 - :issue:`6231`: Improve check for misspelling of :ref:`pytest.mark.parametrize ref`.
5011
5012
5013 - :issue:`6257`: Handle :func:`pytest.exit` being used via :hook:`pytest_internalerror`, e.g. when quitting pdb from post mortem.
5014
5015
5016
5017 Bug Fixes
5018 ---------
5019
5020 - :issue:`5914`: pytester: fix :py:func:`~pytest.LineMatcher.no_fnmatch_line` when used after positive matching.
5021
5022
5023 - :issue:`6082`: Fix line detection for doctest samples inside
5024 :py:class:`python:property` docstrings, as a workaround to
5025 :issue:`python/cpython#61648`.
5026
5027
5028 - :issue:`6254`: Fix compatibility with pytest-parallel (regression in pytest 5.3.0).
5029
5030
5031 - :issue:`6255`: Clear the :py:data:`sys.last_traceback`, :py:data:`sys.last_type`
5032 and :py:data:`sys.last_value` attributes by deleting them instead
5033 of setting them to ``None``. This better matches the behaviour of
5034 the Python standard library.
5035
5036
5037 pytest 5.3.0 (2019-11-19)
5038 =========================
5039
5040 Deprecations
5041 ------------
5042
5043 - :issue:`6179`: The default value of :confval:`junit_family` option will change to ``"xunit2"`` in pytest 6.0, given
5044 that this is the version supported by default in modern tools that manipulate this type of file.
5045
5046 In order to smooth the transition, pytest will issue a warning in case the ``--junitxml`` option
5047 is given in the command line but :confval:`junit_family` is not explicitly configured in ``pytest.ini``.
5048
5049 For more information, :ref:`see the docs <junit-family changed default value>`.
5050
5051
5052
5053 Features
5054 --------
5055
5056 - :issue:`4488`: The pytest team has created the `pytest-reportlog <https://github.com/pytest-dev/pytest-reportlog>`__
5057 plugin, which provides a new ``--report-log=FILE`` option that writes *report logs* into a file as the test session executes.
5058
5059 Each line of the report log contains a self contained JSON object corresponding to a testing event,
5060 such as a collection or a test result report. The file is guaranteed to be flushed after writing
5061 each line, so systems can read and process events in real-time.
5062
5063 The plugin is meant to replace the ``--resultlog`` option, which is deprecated and meant to be removed
5064 in a future release. If you use ``--resultlog``, please try out ``pytest-reportlog`` and
5065 provide feedback.
5066
5067
5068 - :issue:`4730`: When :py:data:`sys.pycache_prefix` (Python 3.8+) is set, it will be used by pytest to cache test files changed by the assertion rewriting mechanism.
5069
5070 This makes it easier to benefit of cached ``.pyc`` files even on file systems without permissions.
5071
5072
5073 - :issue:`5515`: Allow selective auto-indentation of multiline log messages.
5074
5075 Adds command line option ``--log-auto-indent``, config option
5076 :confval:`log_auto_indent` and support for per-entry configuration of
5077 indentation behavior on calls to :py:func:`python:logging.log()`.
5078
5079 Alters the default for auto-indention from ``"on"`` to ``"off"``. This
5080 restores the older behavior that existed prior to v4.6.0. This
5081 reversion to earlier behavior was done because it is better to
5082 activate new features that may lead to broken tests explicitly
5083 rather than implicitly.
5084
5085
5086 - :issue:`5914`: :fixture:`testdir` learned two new functions, :py:func:`~pytest.LineMatcher.no_fnmatch_line` and
5087 :py:func:`~pytest.LineMatcher.no_re_match_line`.
5088
5089 The functions are used to ensure the captured text *does not* match the given
5090 pattern.
5091
5092 The previous idiom was to use :py:func:`python:re.match`:
5093
5094 .. code-block:: python
5095
5096 result = testdir.runpytest()
5097 assert re.match(pat, result.stdout.str()) is None
5098
5099 Or the ``in`` operator:
5100
5101 .. code-block:: python
5102
5103 result = testdir.runpytest()
5104 assert text in result.stdout.str()
5105
5106 But the new functions produce best output on failure.
5107
5108
5109 - :issue:`6057`: Added tolerances to complex values when printing ``pytest.approx``.
5110
5111 For example, ``repr(pytest.approx(3+4j))`` returns ``(3+4j) ± 5e-06 ∠ ±180°``. This is polar notation indicating a circle around the expected value, with a radius of 5e-06. For ``approx`` comparisons to return ``True``, the actual value should fall within this circle.
5112
5113
5114 - :issue:`6061`: Added the pluginmanager as an argument to ``pytest_addoption``
5115 so that hooks can be invoked when setting up command line options. This is
5116 useful for having one plugin communicate things to another plugin,
5117 such as default values or which set of command line options to add.
5118
5119
5120
5121 Improvements
5122 ------------
5123
5124 - :issue:`5061`: Use multiple colors with terminal summary statistics.
5125
5126
5127 - :issue:`5630`: Quitting from debuggers is now properly handled in ``doctest`` items.
5128
5129
5130 - :issue:`5924`: Improved verbose diff output with sequences.
5131
5132 Before:
5133
5134 ::
5135
5136 E AssertionError: assert ['version', '...version_info'] == ['version', '...version', ...]
5137 E Right contains 3 more items, first extra item: ' '
5138 E Full diff:
5139 E - ['version', 'version_info', 'sys.version', 'sys.version_info']
5140 E + ['version',
5141 E + 'version_info',
5142 E + 'sys.version',
5143 E + 'sys.version_info',
5144 E + ' ',
5145 E + 'sys.version',
5146 E + 'sys.version_info']
5147
5148 After:
5149
5150 ::
5151
5152 E AssertionError: assert ['version', '...version_info'] == ['version', '...version', ...]
5153 E Right contains 3 more items, first extra item: ' '
5154 E Full diff:
5155 E [
5156 E 'version',
5157 E 'version_info',
5158 E 'sys.version',
5159 E 'sys.version_info',
5160 E + ' ',
5161 E + 'sys.version',
5162 E + 'sys.version_info',
5163 E ]
5164
5165
5166 - :issue:`5934`: ``repr`` of ``ExceptionInfo`` objects has been improved to honor the ``__repr__`` method of the underlying exception.
5167
5168 - :issue:`5936`: Display untruncated assertion message with ``-vv``.
5169
5170
5171 - :issue:`5990`: Fixed plurality mismatch in test summary (e.g. display "1 error" instead of "1 errors").
5172
5173
5174 - :issue:`6008`: ``Config.InvocationParams.args`` is now always a ``tuple`` to better convey that it should be
5175 immutable and avoid accidental modifications.
5176
5177
5178 - :issue:`6023`: ``pytest.main`` returns a ``pytest.ExitCode`` instance now, except for when custom exit codes are used (where it returns ``int`` then still).
5179
5180
5181 - :issue:`6026`: Align prefixes in output of pytester's ``LineMatcher``.
5182
5183
5184 - :issue:`6059`: Collection errors are reported as errors (and not failures like before) in the terminal's short test summary.
5185
5186
5187 - :issue:`6069`: ``pytester.spawn`` does not skip/xfail tests on FreeBSD anymore unconditionally.
5188
5189
5190 - :issue:`6097`: The "[...%]" indicator in the test summary is now colored according to the final (new) multi-colored line's main color.
5191
5192
5193 - :issue:`6116`: Added ``--co`` as a synonym to ``--collect-only``.
5194
5195
5196 - :issue:`6148`: ``atomicwrites`` is now only used on Windows, fixing a performance regression with assertion rewriting on Unix.
5197
5198
5199 - :issue:`6152`: Now parametrization will use the ``__name__`` attribute of any object for the id, if present. Previously it would only use ``__name__`` for functions and classes.
5200
5201
5202 - :issue:`6176`: Improved failure reporting with pytester's ``Hookrecorder.assertoutcome``.
5203
5204
5205 - :issue:`6181`: The reason for a stopped session, e.g. with ``--maxfail`` / ``-x``, now gets reported in the test summary.
5206
5207
5208 - :issue:`6206`: Improved ``cache.set`` robustness and performance.
5209
5210
5211
5212 Bug Fixes
5213 ---------
5214
5215 - :issue:`2049`: Fixed ``--setup-plan`` showing inaccurate information about fixture lifetimes.
5216
5217
5218 - :issue:`2548`: Fixed line offset mismatch of skipped tests in terminal summary.
5219
5220
5221 - :issue:`6039`: The ``PytestDoctestRunner`` is now properly invalidated when unconfiguring the doctest plugin.
5222
5223 This is important when used with ``pytester``'s ``runpytest_inprocess``.
5224
5225
5226 - :issue:`6047`: BaseExceptions are now handled in ``saferepr``, which includes ``pytest.fail.Exception`` etc.
5227
5228
5229 - :issue:`6074`: pytester: fixed order of arguments in ``rm_rf`` warning when cleaning up temporary directories, and do not emit warnings for errors with ``os.open``.
5230
5231
5232 - :issue:`6189`: Fixed result of ``getmodpath`` method.
5233
5234
5235
5236 Trivial/Internal Changes
5237 ------------------------
5238
5239 - :issue:`4901`: ``RunResult`` from ``pytester`` now displays the mnemonic of the ``ret`` attribute when it is a
5240 valid ``pytest.ExitCode`` value.
5241
5242
5243 pytest 5.2.4 (2019-11-15)
5244 =========================
5245
5246 Bug Fixes
5247 ---------
5248
5249 - :issue:`6194`: Fix incorrect discovery of non-test ``__init__.py`` files.
5250
5251
5252 - :issue:`6197`: Revert "The first test in a package (``__init__.py``) marked with ``@pytest.mark.skip`` is now correctly skipped.".
5253
5254
5255 pytest 5.2.3 (2019-11-14)
5256 =========================
5257
5258 Bug Fixes
5259 ---------
5260
5261 - :issue:`5830`: The first test in a package (``__init__.py``) marked with ``@pytest.mark.skip`` is now correctly skipped.
5262
5263
5264 - :issue:`6099`: Fix ``--trace`` when used with parametrized functions.
5265
5266
5267 - :issue:`6183`: Using ``request`` as a parameter name in ``@pytest.mark.parametrize`` now produces a more
5268 user-friendly error.
5269
5270
5271 pytest 5.2.2 (2019-10-24)
5272 =========================
5273
5274 Bug Fixes
5275 ---------
5276
5277 - :issue:`5206`: Fix ``--nf`` to not forget about known nodeids with partial test selection.
5278
5279
5280 - :issue:`5906`: Fix crash with ``KeyboardInterrupt`` during ``--setup-show``.
5281
5282
5283 - :issue:`5946`: Fixed issue when parametrizing fixtures with numpy arrays (and possibly other sequence-like types).
5284
5285
5286 - :issue:`6044`: Properly ignore ``FileNotFoundError`` exceptions when trying to remove old temporary directories,
5287 for instance when multiple processes try to remove the same directory (common with ``pytest-xdist``
5288 for example).
5289
5290
5291 pytest 5.2.1 (2019-10-06)
5292 =========================
5293
5294 Bug Fixes
5295 ---------
5296
5297 - :issue:`5902`: Fix warnings about deprecated ``cmp`` attribute in ``attrs>=19.2``.
5298
5299
5300 pytest 5.2.0 (2019-09-28)
5301 =========================
5302
5303 Deprecations
5304 ------------
5305
5306 - :issue:`1682`: Passing arguments to pytest.fixture() as positional arguments is deprecated - pass them
5307 as a keyword argument instead.
5308
5309
5310
5311 Features
5312 --------
5313
5314 - :issue:`1682`: The ``scope`` parameter of ``@pytest.fixture`` can now be a callable that receives
5315 the fixture name and the ``config`` object as keyword-only parameters.
5316 See :ref:`the docs <dynamic scope>` for more information.
5317
5318
5319 - :issue:`5764`: New behavior of the ``--pastebin`` option: failures to connect to the pastebin server are reported, without failing the pytest run
5320
5321
5322
5323 Bug Fixes
5324 ---------
5325
5326 - :issue:`5806`: Fix "lexer" being used when uploading to bpaste.net from ``--pastebin`` to "text".
5327
5328
5329 - :issue:`5884`: Fix ``--setup-only`` and ``--setup-show`` for custom pytest items.
5330
5331
5332
5333 Trivial/Internal Changes
5334 ------------------------
5335
5336 - :issue:`5056`: The HelpFormatter uses ``py.io.get_terminal_width`` for better width detection.
5337
5338
5339 pytest 5.1.3 (2019-09-18)
5340 =========================
5341
5342 Bug Fixes
5343 ---------
5344
5345 - :issue:`5807`: Fix pypy3.6 (nightly) on windows.
5346
5347
5348 - :issue:`5811`: Handle ``--fulltrace`` correctly with ``pytest.raises``.
5349
5350
5351 - :issue:`5819`: Windows: Fix regression with conftest whose qualified name contains uppercase
5352 characters (introduced by #5792).
5353
5354
5355 pytest 5.1.2 (2019-08-30)
5356 =========================
5357
5358 Bug Fixes
5359 ---------
5360
5361 - :issue:`2270`: Fixed ``self`` reference in function-scoped fixtures defined plugin classes: previously ``self``
5362 would be a reference to a *test* class, not the *plugin* class.
5363
5364
5365 - :issue:`570`: Fixed long standing issue where fixture scope was not respected when indirect fixtures were used during
5366 parametrization.
5367
5368
5369 - :issue:`5782`: Fix decoding error when printing an error response from ``--pastebin``.
5370
5371
5372 - :issue:`5786`: Chained exceptions in test and collection reports are now correctly serialized, allowing plugins like
5373 ``pytest-xdist`` to display them properly.
5374
5375
5376 - :issue:`5792`: Windows: Fix error that occurs in certain circumstances when loading
5377 ``conftest.py`` from a working directory that has casing other than the one stored
5378 in the filesystem (e.g., ``c:\test`` instead of ``C:\test``).
5379
5380
5381 pytest 5.1.1 (2019-08-20)
5382 =========================
5383
5384 Bug Fixes
5385 ---------
5386
5387 - :issue:`5751`: Fixed ``TypeError`` when importing pytest on Python 3.5.0 and 3.5.1.
5388
5389
5390 pytest 5.1.0 (2019-08-15)
5391 =========================
5392
5393 Removals
5394 --------
5395
5396 - :issue:`5180`: As per our policy, the following features have been deprecated in the 4.X series and are now
5397 removed:
5398
5399 * ``Request.getfuncargvalue``: use ``Request.getfixturevalue`` instead.
5400
5401 * ``pytest.raises`` and ``pytest.warns`` no longer support strings as the second argument.
5402
5403 * ``message`` parameter of ``pytest.raises``.
5404
5405 * ``pytest.raises``, ``pytest.warns`` and ``ParameterSet.param`` now use native keyword-only
5406 syntax. This might change the exception message from previous versions, but they still raise
5407 ``TypeError`` on unknown keyword arguments as before.
5408
5409 * ``pytest.config`` global variable.
5410
5411 * ``tmpdir_factory.ensuretemp`` method.
5412
5413 * ``pytest_logwarning`` hook.
5414
5415 * ``RemovedInPytest4Warning`` warning type.
5416
5417 * ``request`` is now a reserved name for fixtures.
5418
5419
5420 For more information consult :std:doc:`deprecations` in the docs.
5421
5422
5423 - :issue:`5565`: Removed unused support code for :pypi:`unittest2`.
5424
5425 The ``unittest2`` backport module is no longer
5426 necessary since Python 3.3+, and the small amount of code in pytest to support it also doesn't seem
5427 to be used: after removed, all tests still pass unchanged.
5428
5429 Although our policy is to introduce a deprecation period before removing any features or support
5430 for third party libraries, because this code is apparently not used
5431 at all (even if ``unittest2`` is used by a test suite executed by pytest), it was decided to
5432 remove it in this release.
5433
5434 If you experience a regression because of this, please :issue:`file an issue <new>`.
5435
5436
5437 - :issue:`5615`: ``pytest.fail``, ``pytest.xfail`` and ``pytest.skip`` no longer support bytes for the message argument.
5438
5439 This was supported for Python 2 where it was tempting to use ``"message"``
5440 instead of ``u"message"``.
5441
5442 Python 3 code is unlikely to pass ``bytes`` to these functions. If you do,
5443 please decode it to an ``str`` beforehand.
5444
5445
5446
5447 Features
5448 --------
5449
5450 - :issue:`5564`: New ``Config.invocation_args`` attribute containing the unchanged arguments passed to ``pytest.main()``.
5451
5452
5453 - :issue:`5576`: New :ref:`NUMBER <using doctest options>`
5454 option for doctests to ignore irrelevant differences in floating-point numbers.
5455 Inspired by Sébastien Boisgérault's `numtest <https://github.com/boisgera/numtest>`__
5456 extension for doctest.
5457
5458
5459
5460 Improvements
5461 ------------
5462
5463 - :issue:`5471`: JUnit XML now includes a timestamp and hostname in the testsuite tag.
5464
5465
5466 - :issue:`5707`: Time taken to run the test suite now includes a human-readable representation when it takes over
5467 60 seconds, for example::
5468
5469 ===== 2 failed in 102.70s (0:01:42) =====
5470
5471
5472
5473 Bug Fixes
5474 ---------
5475
5476 - :issue:`4344`: Fix RuntimeError/StopIteration when trying to collect package with "__init__.py" only.
5477
5478
5479 - :issue:`5115`: Warnings issued during ``pytest_configure`` are explicitly not treated as errors, even if configured as such, because it otherwise completely breaks pytest.
5480
5481
5482 - :issue:`5477`: The XML file produced by ``--junitxml`` now correctly contain a ``<testsuites>`` root element.
5483
5484
5485 - :issue:`5524`: Fix issue where ``tmp_path`` and ``tmpdir`` would not remove directories containing files marked as read-only,
5486 which could lead to pytest crashing when executed a second time with the ``--basetemp`` option.
5487
5488
5489 - :issue:`5537`: Replace ``importlib_metadata`` backport with ``importlib.metadata`` from the
5490 standard library on Python 3.8+.
5491
5492
5493 - :issue:`5578`: Improve type checking for some exception-raising functions (``pytest.xfail``, ``pytest.skip``, etc)
5494 so they provide better error messages when users meant to use marks (for example ``@pytest.xfail``
5495 instead of ``@pytest.mark.xfail``).
5496
5497
5498 - :issue:`5606`: Fixed internal error when test functions were patched with objects that cannot be compared
5499 for truth values against others, like ``numpy`` arrays.
5500
5501
5502 - :issue:`5634`: ``pytest.exit`` is now correctly handled in ``unittest`` cases.
5503 This makes ``unittest`` cases handle ``quit`` from pytest's pdb correctly.
5504
5505
5506 - :issue:`5650`: Improved output when parsing an ini configuration file fails.
5507
5508
5509 - :issue:`5701`: Fix collection of ``staticmethod`` objects defined with ``functools.partial``.
5510
5511
5512 - :issue:`5734`: Skip async generator test functions, and update the warning message to refer to ``async def`` functions.
5513
5514
5515
5516 Improved Documentation
5517 ----------------------
5518
5519 - :issue:`5669`: Add docstring for ``Testdir.copy_example``.
5520
5521
5522
5523 Trivial/Internal Changes
5524 ------------------------
5525
5526 - :issue:`5095`: XML files of the ``xunit2`` family are now validated against the schema by pytest's own test suite
5527 to avoid future regressions.
5528
5529
5530 - :issue:`5516`: Cache node splitting function which can improve collection performance in very large test suites.
5531
5532
5533 - :issue:`5603`: Simplified internal ``SafeRepr`` class and removed some dead code.
5534
5535
5536 - :issue:`5664`: When invoking pytest's own testsuite with ``PYTHONDONTWRITEBYTECODE=1``,
5537 the ``test_xfail_handling`` test no longer fails.
5538
5539
5540 - :issue:`5684`: Replace manual handling of ``OSError.errno`` in the codebase by new ``OSError`` subclasses (``PermissionError``, ``FileNotFoundError``, etc.).
5541
5542
5543 pytest 5.0.1 (2019-07-04)
5544 =========================
5545
5546 Bug Fixes
5547 ---------
5548
5549 - :issue:`5479`: Improve quoting in ``raises`` match failure message.
5550
5551
5552 - :issue:`5523`: Fixed using multiple short options together in the command-line (for example ``-vs``) in Python 3.8+.
5553
5554
5555 - :issue:`5547`: ``--step-wise`` now handles ``xfail(strict=True)`` markers properly.
5556
5557
5558
5559 Improved Documentation
5560 ----------------------
5561
5562 - :issue:`5517`: Improve "Declaring new hooks" section in chapter "Writing Plugins"
5563
5564
5565 pytest 5.0.0 (2019-06-28)
5566 =========================
5567
5568 Important
5569 ---------
5570
5571 This release is a Python3.5+ only release.
5572
5573 For more details, see our `Python 2.7 and 3.4 support plan
5574 <https://docs.pytest.org/en/7.0.x/py27-py34-deprecation.html>`_.
5575
5576 Removals
5577 --------
5578
5579 - :issue:`1149`: Pytest no longer accepts prefixes of command-line arguments, for example
5580 typing ``pytest --doctest-mod`` inplace of ``--doctest-modules``.
5581 This was previously allowed where the ``ArgumentParser`` thought it was unambiguous,
5582 but this could be incorrect due to delayed parsing of options for plugins.
5583 See for example issues :issue:`1149`,
5584 :issue:`3413`, and
5585 :issue:`4009`.
5586
5587
5588 - :issue:`5402`: **PytestDeprecationWarning are now errors by default.**
5589
5590 Following our plan to remove deprecated features with as little disruption as
5591 possible, all warnings of type ``PytestDeprecationWarning`` now generate errors
5592 instead of warning messages.
5593
5594 **The affected features will be effectively removed in pytest 5.1**, so please consult the
5595 :std:doc:`deprecations` section in the docs for directions on how to update existing code.
5596
5597 In the pytest ``5.0.X`` series, it is possible to change the errors back into warnings as a stop
5598 gap measure by adding this to your ``pytest.ini`` file:
5599
5600 .. code-block:: ini
5601
5602 [pytest]
5603 filterwarnings =
5604 ignore::pytest.PytestDeprecationWarning
5605
5606 But this will stop working when pytest ``5.1`` is released.
5607
5608 **If you have concerns** about the removal of a specific feature, please add a
5609 comment to :issue:`5402`.
5610
5611
5612 - :issue:`5412`: ``ExceptionInfo`` objects (returned by ``pytest.raises``) now have the same ``str`` representation as ``repr``, which
5613 avoids some confusion when users use ``print(e)`` to inspect the object.
5614
5615 This means code like:
5616
5617 .. code-block:: python
5618
5619 with pytest.raises(SomeException) as e:
5620 ...
5621 assert "some message" in str(e)
5622
5623
5624 Needs to be changed to:
5625
5626 .. code-block:: python
5627
5628 with pytest.raises(SomeException) as e:
5629 ...
5630 assert "some message" in str(e.value)
5631
5632
5633
5634
5635 Deprecations
5636 ------------
5637
5638 - :issue:`4488`: The removal of the ``--result-log`` option and module has been postponed to (tentatively) pytest 6.0 as
5639 the team has not yet got around to implement a good alternative for it.
5640
5641
5642 - :issue:`466`: The ``funcargnames`` attribute has been an alias for ``fixturenames`` since
5643 pytest 2.3, and is now deprecated in code too.
5644
5645
5646
5647 Features
5648 --------
5649
5650 - :issue:`3457`: New :hook:`pytest_assertion_pass`
5651 hook, called with context information when an assertion *passes*.
5652
5653 This hook is still **experimental** so use it with caution.
5654
5655
5656 - :issue:`5440`: The :mod:`faulthandler` standard library
5657 module is now enabled by default to help users diagnose crashes in C modules.
5658
5659 This functionality was provided by integrating the external
5660 `pytest-faulthandler <https://github.com/pytest-dev/pytest-faulthandler>`__ plugin into the core,
5661 so users should remove that plugin from their requirements if used.
5662
5663 For more information see the docs: :ref:`faulthandler`.
5664
5665
5666 - :issue:`5452`: When warnings are configured as errors, pytest warnings now appear as originating from ``pytest.`` instead of the internal ``_pytest.warning_types.`` module.
5667
5668
5669 - :issue:`5125`: ``Session.exitcode`` values are now coded in ``pytest.ExitCode``, an ``IntEnum``. This makes the exit code available for consumer code and are more explicit other than just documentation. User defined exit codes are still valid, but should be used with caution.
5670
5671 The team doesn't expect this change to break test suites or plugins in general, except in esoteric/specific scenarios.
5672
5673 **pytest-xdist** users should upgrade to ``1.29.0`` or later, as ``pytest-xdist`` required a compatibility fix because of this change.
5674
5675
5676
5677 Bug Fixes
5678 ---------
5679
5680 - :issue:`1403`: Switch from ``imp`` to ``importlib``.
5681
5682
5683 - :issue:`1671`: The name of the ``.pyc`` files cached by the assertion writer now includes the pytest version
5684 to avoid stale caches.
5685
5686
5687 - :issue:`2761`: Honor :pep:`235` on case-insensitive file systems.
5688
5689
5690 - :issue:`5078`: Test module is no longer double-imported when using ``--pyargs``.
5691
5692
5693 - :issue:`5260`: Improved comparison of byte strings.
5694
5695 When comparing bytes, the assertion message used to show the byte numeric value when showing the differences::
5696
5697 def test():
5698 > assert b'spam' == b'eggs'
5699 E AssertionError: assert b'spam' == b'eggs'
5700 E At index 0 diff: 115 != 101
5701 E Use -v to get the full diff
5702
5703 It now shows the actual ascii representation instead, which is often more useful::
5704
5705 def test():
5706 > assert b'spam' == b'eggs'
5707 E AssertionError: assert b'spam' == b'eggs'
5708 E At index 0 diff: b's' != b'e'
5709 E Use -v to get the full diff
5710
5711
5712 - :issue:`5335`: Colorize level names when the level in the logging format is formatted using
5713 '%(levelname).Xs' (truncated fixed width alignment), where X is an integer.
5714
5715
5716 - :issue:`5354`: Fix ``pytest.mark.parametrize`` when the argvalues is an iterator.
5717
5718
5719 - :issue:`5370`: Revert unrolling of ``all()`` to fix ``NameError`` on nested comprehensions.
5720
5721
5722 - :issue:`5371`: Revert unrolling of ``all()`` to fix incorrect handling of generators with ``if``.
5723
5724
5725 - :issue:`5372`: Revert unrolling of ``all()`` to fix incorrect assertion when using ``all()`` in an expression.
5726
5727
5728 - :issue:`5383`: ``-q`` has again an impact on the style of the collected items
5729 (``--collect-only``) when ``--log-cli-level`` is used.
5730
5731
5732 - :issue:`5389`: Fix regressions of :pr:`5063` for ``importlib_metadata.PathDistribution`` which have their ``files`` attribute being ``None``.
5733
5734
5735 - :issue:`5390`: Fix regression where the ``obj`` attribute of ``TestCase`` items was no longer bound to methods.
5736
5737
5738 - :issue:`5404`: Emit a warning when attempting to unwrap a broken object raises an exception,
5739 for easier debugging (:issue:`5080`).
5740
5741
5742 - :issue:`5432`: Prevent "already imported" warnings from assertion rewriter when invoking pytest in-process multiple times.
5743
5744
5745 - :issue:`5433`: Fix assertion rewriting in packages (``__init__.py``).
5746
5747
5748 - :issue:`5444`: Fix ``--stepwise`` mode when the first file passed on the command-line fails to collect.
5749
5750
5751 - :issue:`5482`: Fix bug introduced in 4.6.0 causing collection errors when passing
5752 more than 2 positional arguments to ``pytest.mark.parametrize``.
5753
5754
5755 - :issue:`5505`: Fix crash when discovery fails while using ``-p no:terminal``.
5756
5757
5758
5759 Improved Documentation
5760 ----------------------
5761
5762 - :issue:`5315`: Expand docs on mocking classes and dictionaries with ``monkeypatch``.
5763
5764
5765 - :issue:`5416`: Fix PytestUnknownMarkWarning in run/skip example.
5766
5767
5768 pytest 4.6.11 (2020-06-04)
5769 ==========================
5770
5771 Bug Fixes
5772 ---------
5773
5774 - :issue:`6334`: Fix summary entries appearing twice when ``f/F`` and ``s/S`` report chars were used at the same time in the ``-r`` command-line option (for example ``-rFf``).
5775
5776 The upper case variants were never documented and the preferred form should be the lower case.
5777
5778
5779 - :issue:`7310`: Fix ``UnboundLocalError: local variable 'letter' referenced before
5780 assignment`` in ``_pytest.terminal.pytest_report_teststatus()``
5781 when plugins return report objects in an unconventional state.
5782
5783 This was making ``pytest_report_teststatus()`` skip
5784 entering if-block branches that declare the ``letter`` variable.
5785
5786 The fix was to set the initial value of the ``letter`` before
5787 the if-block cascade so that it always has a value.
5788
5789
5790 pytest 4.6.10 (2020-05-08)
5791 ==========================
5792
5793 Features
5794 --------
5795
5796 - :issue:`6870`: New ``Config.invocation_args`` attribute containing the unchanged arguments passed to ``pytest.main()``.
5797
5798 Remark: while this is technically a new feature and according to our
5799 `policy <https://docs.pytest.org/en/7.0.x/py27-py34-deprecation.html#what-goes-into-4-6-x-releases>`_
5800 it should not have been backported, we have opened an exception in this
5801 particular case because it fixes a serious interaction with ``pytest-xdist``,
5802 so it can also be considered a bugfix.
5803
5804 Trivial/Internal Changes
5805 ------------------------
5806
5807 - :issue:`6404`: Remove usage of ``parser`` module, deprecated in Python 3.9.
5808
5809
5810 pytest 4.6.9 (2020-01-04)
5811 =========================
5812
5813 Bug Fixes
5814 ---------
5815
5816 - :issue:`6301`: Fix assertion rewriting for egg-based distributions and ``editable`` installs (``pip install --editable``).
5817
5818
5819 pytest 4.6.8 (2019-12-19)
5820 =========================
5821
5822 Features
5823 --------
5824
5825 - :issue:`5471`: JUnit XML now includes a timestamp and hostname in the testsuite tag.
5826
5827
5828
5829 Bug Fixes
5830 ---------
5831
5832 - :issue:`5430`: junitxml: Logs for failed test are now passed to junit report in case the test fails during call phase.
5833
5834
5835
5836 Trivial/Internal Changes
5837 ------------------------
5838
5839 - :issue:`6345`: Pin ``colorama`` to ``0.4.1`` only for Python 3.4 so newer Python versions can still receive colorama updates.
5840
5841
5842 pytest 4.6.7 (2019-12-05)
5843 =========================
5844
5845 Bug Fixes
5846 ---------
5847
5848 - :issue:`5477`: The XML file produced by ``--junitxml`` now correctly contain a ``<testsuites>`` root element.
5849
5850
5851 - :issue:`6044`: Properly ignore ``FileNotFoundError`` (``OSError.errno == NOENT`` in Python 2) exceptions when trying to remove old temporary directories,
5852 for instance when multiple processes try to remove the same directory (common with ``pytest-xdist``
5853 for example).
5854
5855
5856 pytest 4.6.6 (2019-10-11)
5857 =========================
5858
5859 Bug Fixes
5860 ---------
5861
5862 - :issue:`5523`: Fixed using multiple short options together in the command-line (for example ``-vs``) in Python 3.8+.
5863
5864
5865 - :issue:`5537`: Replace ``importlib_metadata`` backport with ``importlib.metadata`` from the
5866 standard library on Python 3.8+.
5867
5868
5869 - :issue:`5806`: Fix "lexer" being used when uploading to bpaste.net from ``--pastebin`` to "text".
5870
5871
5872 - :issue:`5902`: Fix warnings about deprecated ``cmp`` attribute in ``attrs>=19.2``.
5873
5874
5875
5876 Trivial/Internal Changes
5877 ------------------------
5878
5879 - :issue:`5801`: Fixes python version checks (detected by ``flake8-2020``) in case python4 becomes a thing.
5880
5881
5882 pytest 4.6.5 (2019-08-05)
5883 =========================
5884
5885 Bug Fixes
5886 ---------
5887
5888 - :issue:`4344`: Fix RuntimeError/StopIteration when trying to collect package with "__init__.py" only.
5889
5890
5891 - :issue:`5478`: Fix encode error when using unicode strings in exceptions with ``pytest.raises``.
5892
5893
5894 - :issue:`5524`: Fix issue where ``tmp_path`` and ``tmpdir`` would not remove directories containing files marked as read-only,
5895 which could lead to pytest crashing when executed a second time with the ``--basetemp`` option.
5896
5897
5898 - :issue:`5547`: ``--step-wise`` now handles ``xfail(strict=True)`` markers properly.
5899
5900
5901 - :issue:`5650`: Improved output when parsing an ini configuration file fails.
5902
5903 pytest 4.6.4 (2019-06-28)
5904 =========================
5905
5906 Bug Fixes
5907 ---------
5908
5909 - :issue:`5404`: Emit a warning when attempting to unwrap a broken object raises an exception,
5910 for easier debugging (:issue:`5080`).
5911
5912
5913 - :issue:`5444`: Fix ``--stepwise`` mode when the first file passed on the command-line fails to collect.
5914
5915
5916 - :issue:`5482`: Fix bug introduced in 4.6.0 causing collection errors when passing
5917 more than 2 positional arguments to ``pytest.mark.parametrize``.
5918
5919
5920 - :issue:`5505`: Fix crash when discovery fails while using ``-p no:terminal``.
5921
5922
5923 pytest 4.6.3 (2019-06-11)
5924 =========================
5925
5926 Bug Fixes
5927 ---------
5928
5929 - :issue:`5383`: ``-q`` has again an impact on the style of the collected items
5930 (``--collect-only``) when ``--log-cli-level`` is used.
5931
5932
5933 - :issue:`5389`: Fix regressions of :pr:`5063` for ``importlib_metadata.PathDistribution`` which have their ``files`` attribute being ``None``.
5934
5935
5936 - :issue:`5390`: Fix regression where the ``obj`` attribute of ``TestCase`` items was no longer bound to methods.
5937
5938
5939 pytest 4.6.2 (2019-06-03)
5940 =========================
5941
5942 Bug Fixes
5943 ---------
5944
5945 - :issue:`5370`: Revert unrolling of ``all()`` to fix ``NameError`` on nested comprehensions.
5946
5947
5948 - :issue:`5371`: Revert unrolling of ``all()`` to fix incorrect handling of generators with ``if``.
5949
5950
5951 - :issue:`5372`: Revert unrolling of ``all()`` to fix incorrect assertion when using ``all()`` in an expression.
5952
5953
5954 pytest 4.6.1 (2019-06-02)
5955 =========================
5956
5957 Bug Fixes
5958 ---------
5959
5960 - :issue:`5354`: Fix ``pytest.mark.parametrize`` when the argvalues is an iterator.
5961
5962
5963 - :issue:`5358`: Fix assertion rewriting of ``all()`` calls to deal with non-generators.
5964
5965
5966 pytest 4.6.0 (2019-05-31)
5967 =========================
5968
5969 Important
5970 ---------
5971
5972 The ``4.6.X`` series will be the last series to support **Python 2 and Python 3.4**.
5973
5974 For more details, see our `Python 2.7 and 3.4 support plan
5975 <https://docs.pytest.org/en/7.0.x/py27-py34-deprecation.html>`_.
5976
5977
5978 Features
5979 --------
5980
5981 - :issue:`4559`: Added the ``junit_log_passing_tests`` ini value which can be used to enable or disable logging of passing test output in the Junit XML file.
5982
5983
5984 - :issue:`4956`: pytester's ``testdir.spawn`` uses ``tmpdir`` as HOME/USERPROFILE directory.
5985
5986
5987 - :issue:`5062`: Unroll calls to ``all`` to full for-loops with assertion rewriting for better failure messages, especially when using Generator Expressions.
5988
5989
5990 - :issue:`5063`: Switch from ``pkg_resources`` to ``importlib-metadata`` for entrypoint detection for improved performance and import time.
5991
5992
5993 - :issue:`5091`: The output for ini options in ``--help`` has been improved.
5994
5995
5996 - :issue:`5269`: ``pytest.importorskip`` includes the ``ImportError`` now in the default ``reason``.
5997
5998
5999 - :issue:`5311`: Captured logs that are output for each failing test are formatted using the
6000 ColoredLevelFormatter.
6001
6002
6003 - :issue:`5312`: Improved formatting of multiline log messages in Python 3.
6004
6005
6006
6007 Bug Fixes
6008 ---------
6009
6010 - :issue:`2064`: The debugging plugin imports the wrapped ``Pdb`` class (``--pdbcls``) on-demand now.
6011
6012
6013 - :issue:`4908`: The ``pytest_enter_pdb`` hook gets called with post-mortem (``--pdb``).
6014
6015
6016 - :issue:`5036`: Fix issue where fixtures dependent on other parametrized fixtures would be erroneously parametrized.
6017
6018
6019 - :issue:`5256`: Handle internal error due to a lone surrogate unicode character not being representable in Jython.
6020
6021
6022 - :issue:`5257`: Ensure that ``sys.stdout.mode`` does not include ``'b'`` as it is a text stream.
6023
6024
6025 - :issue:`5278`: Pytest's internal python plugin can be disabled using ``-p no:python`` again.
6026
6027
6028 - :issue:`5286`: Fix issue with ``disable_test_id_escaping_and_forfeit_all_rights_to_community_support`` option not working when using a list of test IDs in parametrized tests.
6029
6030
6031 - :issue:`5330`: Show the test module being collected when emitting ``PytestCollectionWarning`` messages for
6032 test classes with ``__init__`` and ``__new__`` methods to make it easier to pin down the problem.
6033
6034
6035 - :issue:`5333`: Fix regression in 4.5.0 with ``--lf`` not re-running all tests with known failures from non-selected tests.
6036
6037
6038
6039 Improved Documentation
6040 ----------------------
6041
6042 - :issue:`5250`: Expand docs on use of ``setenv`` and ``delenv`` with ``monkeypatch``.
6043
6044
6045 pytest 4.5.0 (2019-05-11)
6046 =========================
6047
6048 Features
6049 --------
6050
6051 - :issue:`4826`: A warning is now emitted when unknown marks are used as a decorator.
6052 This is often due to a typo, which can lead to silently broken tests.
6053
6054
6055 - :issue:`4907`: Show XFail reason as part of JUnitXML message field.
6056
6057
6058 - :issue:`5013`: Messages from crash reports are displayed within test summaries now, truncated to the terminal width.
6059
6060
6061 - :issue:`5023`: New flag ``--strict-markers`` that triggers an error when unknown markers (e.g. those not registered using the :confval:`markers` option in the configuration file) are used in the test suite.
6062
6063 The existing ``--strict`` option has the same behavior currently, but can be augmented in the future for additional checks.
6064
6065
6066 - :issue:`5026`: Assertion failure messages for sequences and dicts contain the number of different items now.
6067
6068
6069 - :issue:`5034`: Improve reporting with ``--lf`` and ``--ff`` (run-last-failure).
6070
6071
6072 - :issue:`5035`: The ``--cache-show`` option/action accepts an optional glob to show only matching cache entries.
6073
6074
6075 - :issue:`5059`: Standard input (stdin) can be given to pytester's ``Testdir.run()`` and ``Testdir.popen()``.
6076
6077
6078 - :issue:`5068`: The ``-r`` option learnt about ``A`` to display all reports (including passed ones) in the short test summary.
6079
6080
6081 - :issue:`5108`: The short test summary is displayed after passes with output (``-rP``).
6082
6083
6084 - :issue:`5172`: The ``--last-failed`` (``--lf``) option got smarter and will now skip entire files if all tests
6085 of that test file have passed in previous runs, greatly speeding up collection.
6086
6087
6088 - :issue:`5177`: Introduce new specific warning ``PytestWarning`` subclasses to make it easier to filter warnings based on the class, rather than on the message. The new subclasses are:
6089
6090
6091 * ``PytestAssertRewriteWarning``
6092
6093 * ``PytestCacheWarning``
6094
6095 * ``PytestCollectionWarning``
6096
6097 * ``PytestConfigWarning``
6098
6099 * ``PytestUnhandledCoroutineWarning``
6100
6101 * ``PytestUnknownMarkWarning``
6102
6103
6104 - :issue:`5202`: New ``record_testsuite_property`` session-scoped fixture allows users to log ``<property>`` tags at the ``testsuite``
6105 level with the ``junitxml`` plugin.
6106
6107 The generated XML is compatible with the latest xunit standard, contrary to
6108 the properties recorded by ``record_property`` and ``record_xml_attribute``.
6109
6110
6111 - :issue:`5214`: The default logging format has been changed to improve readability. Here is an
6112 example of a previous logging message::
6113
6114 test_log_cli_enabled_disabled.py 3 CRITICAL critical message logged by test
6115
6116 This has now become::
6117
6118 CRITICAL root:test_log_cli_enabled_disabled.py:3 critical message logged by test
6119
6120 The formatting can be changed through the :confval:`log_format` configuration option.
6121
6122
6123 - :issue:`5220`: ``--fixtures`` now also shows fixture scope for scopes other than ``"function"``.
6124
6125
6126
6127 Bug Fixes
6128 ---------
6129
6130 - :issue:`5113`: Deselected items from plugins using ``pytest_collect_modifyitems`` as a hookwrapper are correctly reported now.
6131
6132
6133 - :issue:`5144`: With usage errors ``exitstatus`` is set to ``EXIT_USAGEERROR`` in the ``pytest_sessionfinish`` hook now as expected.
6134
6135
6136 - :issue:`5235`: ``outcome.exit`` is not used with ``EOF`` in the pdb wrapper anymore, but only with ``quit``.
6137
6138
6139
6140 Improved Documentation
6141 ----------------------
6142
6143 - :issue:`4935`: Expand docs on registering marks and the effect of ``--strict``.
6144
6145
6146
6147 Trivial/Internal Changes
6148 ------------------------
6149
6150 - :issue:`4942`: ``logging.raiseExceptions`` is not set to ``False`` anymore.
6151
6152
6153 - :issue:`5013`: pytest now depends on :pypi:`wcwidth` to properly track unicode character sizes for more precise terminal output.
6154
6155
6156 - :issue:`5059`: pytester's ``Testdir.popen()`` uses ``stdout`` and ``stderr`` via keyword arguments with defaults now (``subprocess.PIPE``).
6157
6158
6159 - :issue:`5069`: The code for the short test summary in the terminal was moved to the terminal plugin.
6160
6161
6162 - :issue:`5082`: Improved validation of kwargs for various methods in the pytester plugin.
6163
6164
6165 - :issue:`5202`: ``record_property`` now emits a ``PytestWarning`` when used with ``junit_family=xunit2``: the fixture generates
6166 ``property`` tags as children of ``testcase``, which is not permitted according to the most
6167 `recent schema <https://github.com/jenkinsci/xunit-plugin/blob/master/
6168 src/main/resources/org/jenkinsci/plugins/xunit/types/model/xsd/junit-10.xsd>`__.
6169
6170
6171 - :issue:`5239`: Pin ``pluggy`` to ``< 1.0`` so we don't update to ``1.0`` automatically when
6172 it gets released: there are planned breaking changes, and we want to ensure
6173 pytest properly supports ``pluggy 1.0``.
6174
6175
6176 pytest 4.4.2 (2019-05-08)
6177 =========================
6178
6179 Bug Fixes
6180 ---------
6181
6182 - :issue:`5089`: Fix crash caused by error in ``__repr__`` function with both ``showlocals`` and verbose output enabled.
6183
6184
6185 - :issue:`5139`: Eliminate core dependency on 'terminal' plugin.
6186
6187
6188 - :issue:`5229`: Require ``pluggy>=0.11.0`` which reverts a dependency to ``importlib-metadata`` added in ``0.10.0``.
6189 The ``importlib-metadata`` package cannot be imported when installed as an egg and causes issues when relying on ``setup.py`` to install test dependencies.
6190
6191
6192
6193 Improved Documentation
6194 ----------------------
6195
6196 - :issue:`5171`: Doc: ``pytest_ignore_collect``, ``pytest_collect_directory``, ``pytest_collect_file`` and ``pytest_pycollect_makemodule`` hooks's 'path' parameter documented type is now ``py.path.local``
6197
6198
6199 - :issue:`5188`: Improve help for ``--runxfail`` flag.
6200
6201
6202
6203 Trivial/Internal Changes
6204 ------------------------
6205
6206 - :issue:`5182`: Removed internal and unused ``_pytest.deprecated.MARK_INFO_ATTRIBUTE``.
6207
6208
6209 pytest 4.4.1 (2019-04-15)
6210 =========================
6211
6212 Bug Fixes
6213 ---------
6214
6215 - :issue:`5031`: Environment variables are properly restored when using pytester's ``testdir`` fixture.
6216
6217
6218 - :issue:`5039`: Fix regression with ``--pdbcls``, which stopped working with local modules in 4.0.0.
6219
6220
6221 - :issue:`5092`: Produce a warning when unknown keywords are passed to ``pytest.param(...)``.
6222
6223
6224 - :issue:`5098`: Invalidate import caches with ``monkeypatch.syspath_prepend``, which is required with namespace packages being used.
6225
6226
6227 pytest 4.4.0 (2019-03-29)
6228 =========================
6229
6230 Features
6231 --------
6232
6233 - :issue:`2224`: ``async`` test functions are skipped and a warning is emitted when a suitable
6234 async plugin is not installed (such as ``pytest-asyncio`` or ``pytest-trio``).
6235
6236 Previously ``async`` functions would not execute at all but still be marked as "passed".
6237
6238
6239 - :issue:`2482`: Include new ``disable_test_id_escaping_and_forfeit_all_rights_to_community_support`` option to disable ascii-escaping in parametrized values. This may cause a series of problems and as the name makes clear, use at your own risk.
6240
6241
6242 - :issue:`4718`: The ``-p`` option can now be used to early-load plugins also by entry-point name, instead of just
6243 by module name.
6244
6245 This makes it possible to early load external plugins like ``pytest-cov`` in the command-line::
6246
6247 pytest -p pytest_cov
6248
6249
6250 - :issue:`4855`: The ``--pdbcls`` option handles classes via module attributes now (e.g.
6251 ``pdb:pdb.Pdb`` with :pypi:`pdbpp`), and its validation was improved.
6252
6253
6254 - :issue:`4875`: The :confval:`testpaths` configuration option is now displayed next
6255 to the ``rootdir`` and ``inifile`` lines in the pytest header if the option is in effect, i.e., directories or file names were
6256 not explicitly passed in the command line.
6257
6258 Also, ``inifile`` is only displayed if there's a configuration file, instead of an empty ``inifile:`` string.
6259
6260
6261 - :issue:`4911`: Doctests can be skipped now dynamically using ``pytest.skip()``.
6262
6263
6264 - :issue:`4920`: Internal refactorings have been made in order to make the implementation of the
6265 `pytest-subtests <https://github.com/pytest-dev/pytest-subtests>`__ plugin
6266 possible, which adds unittest sub-test support and a new ``subtests`` fixture as discussed in
6267 :issue:`1367`.
6268
6269 For details on the internal refactorings, please see the details on the related PR.
6270
6271
6272 - :issue:`4931`: pytester's ``LineMatcher`` asserts that the passed lines are a sequence.
6273
6274
6275 - :issue:`4936`: Handle ``-p plug`` after ``-p no:plug``.
6276
6277 This can be used to override a blocked plugin (e.g. in "addopts") from the
6278 command line etc.
6279
6280
6281 - :issue:`4951`: Output capturing is handled correctly when only capturing via fixtures (capsys, capfs) with ``pdb.set_trace()``.
6282
6283
6284 - :issue:`4956`: ``pytester`` sets ``$HOME`` and ``$USERPROFILE`` to the temporary directory during test runs.
6285
6286 This ensures to not load configuration files from the real user's home directory.
6287
6288
6289 - :issue:`4980`: Namespace packages are handled better with ``monkeypatch.syspath_prepend`` and ``testdir.syspathinsert`` (via ``pkg_resources.fixup_namespace_packages``).
6290
6291
6292 - :issue:`4993`: The stepwise plugin reports status information now.
6293
6294
6295 - :issue:`5008`: If a ``setup.cfg`` file contains ``[tool:pytest]`` and also the no longer supported ``[pytest]`` section, pytest will use ``[tool:pytest]`` ignoring ``[pytest]``. Previously it would unconditionally error out.
6296
6297 This makes it simpler for plugins to support old pytest versions.
6298
6299
6300
6301 Bug Fixes
6302 ---------
6303
6304 - :issue:`1895`: Fix bug where fixtures requested dynamically via ``request.getfixturevalue()`` might be teardown
6305 before the requesting fixture.
6306
6307
6308 - :issue:`4851`: pytester unsets ``PYTEST_ADDOPTS`` now to not use outer options with ``testdir.runpytest()``.
6309
6310
6311 - :issue:`4903`: Use the correct modified time for years after 2038 in rewritten ``.pyc`` files.
6312
6313
6314 - :issue:`4928`: Fix line offsets with ``ScopeMismatch`` errors.
6315
6316
6317 - :issue:`4957`: ``-p no:plugin`` is handled correctly for default (internal) plugins now, e.g. with ``-p no:capture``.
6318
6319 Previously they were loaded (imported) always, making e.g. the ``capfd`` fixture available.
6320
6321
6322 - :issue:`4968`: The pdb ``quit`` command is handled properly when used after the ``debug`` command with :pypi:`pdbpp`.
6323
6324
6325 - :issue:`4975`: Fix the interpretation of ``-qq`` option where it was being considered as ``-v`` instead.
6326
6327
6328 - :issue:`4978`: ``outcomes.Exit`` is not swallowed in ``assertrepr_compare`` anymore.
6329
6330
6331 - :issue:`4988`: Close logging's file handler explicitly when the session finishes.
6332
6333
6334 - :issue:`5003`: Fix line offset with mark collection error (off by one).
6335
6336
6337
6338 Improved Documentation
6339 ----------------------
6340
6341 - :issue:`4974`: Update docs for ``pytest_cmdline_parse`` hook to note availability limitations
6342
6343
6344
6345 Trivial/Internal Changes
6346 ------------------------
6347
6348 - :issue:`4718`: ``pluggy>=0.9`` is now required.
6349
6350
6351 - :issue:`4815`: ``funcsigs>=1.0`` is now required for Python 2.7.
6352
6353
6354 - :issue:`4829`: Some left-over internal code related to ``yield`` tests has been removed.
6355
6356
6357 - :issue:`4890`: Remove internally unused ``anypython`` fixture from the pytester plugin.
6358
6359
6360 - :issue:`4912`: Remove deprecated Sphinx directive, ``add_description_unit()``,
6361 pin sphinx-removed-in to >= 0.2.0 to support Sphinx 2.0.
6362
6363
6364 - :issue:`4913`: Fix pytest tests invocation with custom ``PYTHONPATH``.
6365
6366
6367 - :issue:`4965`: New ``pytest_report_to_serializable`` and ``pytest_report_from_serializable`` **experimental** hooks.
6368
6369 These hooks will be used by ``pytest-xdist``, ``pytest-subtests``, and the replacement for
6370 resultlog to serialize and customize reports.
6371
6372 They are experimental, meaning that their details might change or even be removed
6373 completely in future patch releases without warning.
6374
6375 Feedback is welcome from plugin authors and users alike.
6376
6377
6378 - :issue:`4987`: ``Collector.repr_failure`` respects the ``--tb`` option, but only defaults to ``short`` now (with ``auto``).
6379
6380
6381 pytest 4.3.1 (2019-03-11)
6382 =========================
6383
6384 Bug Fixes
6385 ---------
6386
6387 - :issue:`4810`: Logging messages inside ``pytest_runtest_logreport()`` are now properly captured and displayed.
6388
6389
6390 - :issue:`4861`: Improve validation of contents written to captured output so it behaves the same as when capture is disabled.
6391
6392
6393 - :issue:`4898`: Fix ``AttributeError: FixtureRequest has no 'confg' attribute`` bug in ``testdir.copy_example``.
6394
6395
6396
6397 Trivial/Internal Changes
6398 ------------------------
6399
6400 - :issue:`4768`: Avoid pkg_resources import at the top-level.
6401
6402
6403 pytest 4.3.0 (2019-02-16)
6404 =========================
6405
6406 Deprecations
6407 ------------
6408
6409 - :issue:`4724`: ``pytest.warns()`` now emits a warning when it receives unknown keyword arguments.
6410
6411 This will be changed into an error in the future.
6412
6413
6414
6415 Features
6416 --------
6417
6418 - :issue:`2753`: Usage errors from argparse are mapped to pytest's ``UsageError``.
6419
6420
6421 - :issue:`3711`: Add the ``--ignore-glob`` parameter to exclude test-modules with Unix shell-style wildcards.
6422 Add the :globalvar:`collect_ignore_glob` for ``conftest.py`` to exclude test-modules with Unix shell-style wildcards.
6423
6424
6425 - :issue:`4698`: The warning about Python 2.7 and 3.4 not being supported in pytest 5.0 has been removed.
6426
6427 In the end it was considered to be more
6428 of a nuisance than actual utility and users of those Python versions shouldn't have problems as ``pip`` will not
6429 install pytest 5.0 on those interpreters.
6430
6431
6432 - :issue:`4707`: With the help of new ``set_log_path()`` method there is a way to set ``log_file`` paths from hooks.
6433
6434
6435
6436 Bug Fixes
6437 ---------
6438
6439 - :issue:`4651`: ``--help`` and ``--version`` are handled with ``UsageError``.
6440
6441
6442 - :issue:`4782`: Fix ``AssertionError`` with collection of broken symlinks with packages.
6443
6444
6445 pytest 4.2.1 (2019-02-12)
6446 =========================
6447
6448 Bug Fixes
6449 ---------
6450
6451 - :issue:`2895`: The ``pytest_report_collectionfinish`` hook now is also called with ``--collect-only``.
6452
6453
6454 - :issue:`3899`: Do not raise ``UsageError`` when an imported package has a ``pytest_plugins.py`` child module.
6455
6456
6457 - :issue:`4347`: Fix output capturing when using pdb++ with recursive debugging.
6458
6459
6460 - :issue:`4592`: Fix handling of ``collect_ignore`` via parent ``conftest.py``.
6461
6462
6463 - :issue:`4700`: Fix regression where ``setUpClass`` would always be called in subclasses even if all tests
6464 were skipped by a ``unittest.skip()`` decorator applied in the subclass.
6465
6466
6467 - :issue:`4739`: Fix ``parametrize(... ids=<function>)`` when the function returns non-strings.
6468
6469
6470 - :issue:`4745`: Fix/improve collection of args when passing in ``__init__.py`` and a test file.
6471
6472
6473 - :issue:`4770`: ``more_itertools`` is now constrained to <6.0.0 when required for Python 2.7 compatibility.
6474
6475
6476 - :issue:`526`: Fix "ValueError: Plugin already registered" exceptions when running in build directories that symlink to actual source.
6477
6478
6479
6480 Improved Documentation
6481 ----------------------
6482
6483 - :issue:`3899`: Add note to ``plugins.rst`` that ``pytest_plugins`` should not be used as a name for a user module containing plugins.
6484
6485
6486 - :issue:`4324`: Document how to use ``raises`` and ``does_not_raise`` to write parametrized tests with conditional raises.
6487
6488
6489 - :issue:`4709`: Document how to customize test failure messages when using
6490 ``pytest.warns``.
6491
6492
6493
6494 Trivial/Internal Changes
6495 ------------------------
6496
6497 - :issue:`4741`: Some verbosity related attributes of the TerminalReporter plugin are now
6498 read only properties.
6499
6500
6501 pytest 4.2.0 (2019-01-30)
6502 =========================
6503
6504 Features
6505 --------
6506
6507 - :issue:`3094`: :doc:`Classic xunit-style <how-to/xunit_setup>` functions and methods
6508 now obey the scope of *autouse* fixtures.
6509
6510 This fixes a number of surprising issues like ``setup_method`` being called before session-scoped
6511 autouse fixtures (see :issue:`517` for an example).
6512
6513
6514 - :issue:`4627`: Display a message at the end of the test session when running under Python 2.7 and 3.4 that pytest 5.0 will no longer
6515 support those Python versions.
6516
6517
6518 - :issue:`4660`: The number of *selected* tests now are also displayed when the ``-k`` or ``-m`` flags are used.
6519
6520
6521 - :issue:`4688`: ``pytest_report_teststatus`` hook now can also receive a ``config`` parameter.
6522
6523
6524 - :issue:`4691`: ``pytest_terminal_summary`` hook now can also receive a ``config`` parameter.
6525
6526
6527
6528 Bug Fixes
6529 ---------
6530
6531 - :issue:`3547`: ``--junitxml`` can emit XML compatible with Jenkins xUnit.
6532 ``junit_family`` INI option accepts ``legacy|xunit1``, which produces old style output, and ``xunit2`` that conforms more strictly to https://github.com/jenkinsci/xunit-plugin/blob/xunit-2.3.2/src/main/resources/org/jenkinsci/plugins/xunit/types/model/xsd/junit-10.xsd
6533
6534
6535 - :issue:`4280`: Improve quitting from pdb, especially with ``--trace``.
6536
6537 Using ``q[quit]`` after ``pdb.set_trace()`` will quit pytest also.
6538
6539
6540 - :issue:`4402`: Warning summary now groups warnings by message instead of by test id.
6541
6542 This makes the output more compact and better conveys the general idea of how much code is
6543 actually generating warnings, instead of how many tests call that code.
6544
6545
6546 - :issue:`4536`: ``monkeypatch.delattr`` handles class descriptors like ``staticmethod``/``classmethod``.
6547
6548
6549 - :issue:`4649`: Restore marks being considered keywords for keyword expressions.
6550
6551
6552 - :issue:`4653`: ``tmp_path`` fixture and other related ones provides resolved path (a.k.a real path)
6553
6554
6555 - :issue:`4667`: ``pytest_terminal_summary`` uses result from ``pytest_report_teststatus`` hook, rather than hardcoded strings.
6556
6557
6558 - :issue:`4669`: Correctly handle ``unittest.SkipTest`` exception containing non-ascii characters on Python 2.
6559
6560
6561 - :issue:`4680`: Ensure the ``tmpdir`` and the ``tmp_path`` fixtures are the same folder.
6562
6563
6564 - :issue:`4681`: Ensure ``tmp_path`` is always a real path.
6565
6566
6567
6568 Trivial/Internal Changes
6569 ------------------------
6570
6571 - :issue:`4643`: Use ``a.item()`` instead of the deprecated ``np.asscalar(a)`` in ``pytest.approx``.
6572
6573 ``np.asscalar`` has been :doc:`deprecated <numpy:release/1.16.0-notes>` in ``numpy 1.16.``.
6574
6575
6576 - :issue:`4657`: Copy saferepr from pylib
6577
6578
6579 - :issue:`4668`: The verbose word for expected failures in the teststatus report changes from ``xfail`` to ``XFAIL`` to be consistent with other test outcomes.
6580
6581
6582 pytest 4.1.1 (2019-01-12)
6583 =========================
6584
6585 Bug Fixes
6586 ---------
6587
6588 - :issue:`2256`: Show full repr with ``assert a==b`` and ``-vv``.
6589
6590
6591 - :issue:`3456`: Extend Doctest-modules to ignore mock objects.
6592
6593
6594 - :issue:`4617`: Fixed ``pytest.warns`` bug when context manager is reused (e.g. multiple parametrization).
6595
6596
6597 - :issue:`4631`: Don't rewrite assertion when ``__getattr__`` is broken
6598
6599
6600
6601 Improved Documentation
6602 ----------------------
6603
6604 - :issue:`3375`: Document that using ``setup.cfg`` may crash other tools or cause hard to track down problems because it uses a different parser than ``pytest.ini`` or ``tox.ini`` files.
6605
6606
6607
6608 Trivial/Internal Changes
6609 ------------------------
6610
6611 - :issue:`4602`: Uninstall ``hypothesis`` in regen tox env.
6612
6613
6614 pytest 4.1.0 (2019-01-05)
6615 =========================
6616
6617 Removals
6618 --------
6619
6620 - :issue:`2169`: ``pytest.mark.parametrize``: in previous versions, errors raised by id functions were suppressed and changed into warnings. Now the exceptions are propagated, along with a pytest message informing the node, parameter value and index where the exception occurred.
6621
6622
6623 - :issue:`3078`: Remove legacy internal warnings system: ``config.warn``, ``Node.warn``. The ``pytest_logwarning`` now issues a warning when implemented.
6624
6625 See our :ref:`docs <config.warn and node.warn deprecated>` on information on how to update your code.
6626
6627
6628 - :issue:`3079`: Removed support for yield tests - they are fundamentally broken because they don't support fixtures properly since collection and test execution were separated.
6629
6630 See our :ref:`docs <yield tests deprecated>` on information on how to update your code.
6631
6632
6633 - :issue:`3082`: Removed support for applying marks directly to values in ``@pytest.mark.parametrize``. Use ``pytest.param`` instead.
6634
6635 See our :ref:`docs <marks in pytest.parametrize deprecated>` on information on how to update your code.
6636
6637
6638 - :issue:`3083`: Removed ``Metafunc.addcall``. This was the predecessor mechanism to ``@pytest.mark.parametrize``.
6639
6640 See our :ref:`docs <metafunc.addcall deprecated>` on information on how to update your code.
6641
6642
6643 - :issue:`3085`: Removed support for passing strings to ``pytest.main``. Now, always pass a list of strings instead.
6644
6645 See our :ref:`docs <passing command-line string to pytest.main deprecated>` on information on how to update your code.
6646
6647
6648 - :issue:`3086`: ``[pytest]`` section in **setup.cfg** files is no longer supported, use ``[tool:pytest]`` instead. ``setup.cfg`` files
6649 are meant for use with ``distutils``, and a section named ``pytest`` has notoriously been a source of conflicts and bugs.
6650
6651 Note that for **pytest.ini** and **tox.ini** files the section remains ``[pytest]``.
6652
6653
6654 - :issue:`3616`: Removed the deprecated compat properties for ``node.Class/Function/Module`` - use ``pytest.Class/Function/Module`` now.
6655
6656 See our :ref:`docs <internal classes accessed through node deprecated>` on information on how to update your code.
6657
6658
6659 - :issue:`4421`: Removed the implementation of the ``pytest_namespace`` hook.
6660
6661 See our :ref:`docs <pytest.namespace deprecated>` on information on how to update your code.
6662
6663
6664 - :issue:`4489`: Removed ``request.cached_setup``. This was the predecessor mechanism to modern fixtures.
6665
6666 See our :ref:`docs <cached_setup deprecated>` on information on how to update your code.
6667
6668
6669 - :issue:`4535`: Removed the deprecated ``PyCollector.makeitem`` method. This method was made public by mistake a long time ago.
6670
6671
6672 - :issue:`4543`: Removed support to define fixtures using the ``pytest_funcarg__`` prefix. Use the ``@pytest.fixture`` decorator instead.
6673
6674 See our :ref:`docs <pytest_funcarg__ prefix deprecated>` on information on how to update your code.
6675
6676
6677 - :issue:`4545`: Calling fixtures directly is now always an error instead of a warning.
6678
6679 See our :ref:`docs <calling fixtures directly deprecated>` on information on how to update your code.
6680
6681
6682 - :issue:`4546`: Remove ``Node.get_marker(name)`` the return value was not usable for more than an existence check.
6683
6684 Use ``Node.get_closest_marker(name)`` as a replacement.
6685
6686
6687 - :issue:`4547`: The deprecated ``record_xml_property`` fixture has been removed, use the more generic ``record_property`` instead.
6688
6689 See our :ref:`docs <record_xml_property deprecated>` for more information.
6690
6691
6692 - :issue:`4548`: An error is now raised if the ``pytest_plugins`` variable is defined in a non-top-level ``conftest.py`` file (i.e., not residing in the ``rootdir``).
6693
6694 See our :ref:`docs <pytest_plugins in non-top-level conftest files deprecated>` for more information.
6695
6696
6697 - :issue:`891`: Remove ``testfunction.markername`` attributes - use ``Node.iter_markers(name=None)`` to iterate them.
6698
6699
6700
6701 Deprecations
6702 ------------
6703
6704 - :issue:`3050`: Deprecated the ``pytest.config`` global.
6705
6706 See :ref:`pytest.config global deprecated` for rationale.
6707
6708
6709 - :issue:`3974`: Passing the ``message`` parameter of ``pytest.raises`` now issues a ``DeprecationWarning``.
6710
6711 It is a common mistake to think this parameter will match the exception message, while in fact
6712 it only serves to provide a custom message in case the ``pytest.raises`` check fails. To avoid this
6713 mistake and because it is believed to be little used, pytest is deprecating it without providing
6714 an alternative for the moment.
6715
6716 If you have concerns about this, please comment on :issue:`3974`.
6717
6718
6719 - :issue:`4435`: Deprecated ``raises(..., 'code(as_a_string)')`` and ``warns(..., 'code(as_a_string)')``.
6720
6721 See :std:ref:`raises-warns-exec` for rationale and examples.
6722
6723
6724
6725 Features
6726 --------
6727
6728 - :issue:`3191`: A warning is now issued when assertions are made for ``None``.
6729
6730 This is a common source of confusion among new users, which write:
6731
6732 .. code-block:: python
6733
6734 assert mocked_object.assert_called_with(3, 4, 5, key="value")
6735
6736 When they should write:
6737
6738 .. code-block:: python
6739
6740 mocked_object.assert_called_with(3, 4, 5, key="value")
6741
6742 Because the ``assert_called_with`` method of mock objects already executes an assertion.
6743
6744 This warning will not be issued when ``None`` is explicitly checked. An assertion like:
6745
6746 .. code-block:: python
6747
6748 assert variable is None
6749
6750 will not issue the warning.
6751
6752
6753 - :issue:`3632`: Richer equality comparison introspection on ``AssertionError`` for objects created using `attrs <https://www.attrs.org/en/stable/>`__ or :mod:`dataclasses` (Python 3.7+, :pypi:`backported to 3.6 <dataclasses>`).
6754
6755
6756 - :issue:`4278`: ``CACHEDIR.TAG`` files are now created inside cache directories.
6757
6758 Those files are part of the `Cache Directory Tagging Standard <https://bford.info/cachedir/spec.html>`__, and can
6759 be used by backup or synchronization programs to identify pytest's cache directory as such.
6760
6761
6762 - :issue:`4292`: ``pytest.outcomes.Exit`` is derived from ``SystemExit`` instead of ``KeyboardInterrupt``. This allows us to better handle ``pdb`` exiting.
6763
6764
6765 - :issue:`4371`: Updated the ``--collect-only`` option to display test descriptions when ran using ``--verbose``.
6766
6767
6768 - :issue:`4386`: Restructured ``ExceptionInfo`` object construction and ensure incomplete instances have a ``repr``/``str``.
6769
6770
6771 - :issue:`4416`: pdb: added support for keyword arguments with ``pdb.set_trace``.
6772
6773 It handles ``header`` similar to Python 3.7 does it, and forwards any
6774 other keyword arguments to the ``Pdb`` constructor.
6775
6776 This allows for ``__import__("pdb").set_trace(skip=["foo.*"])``.
6777
6778
6779 - :issue:`4483`: Added ini parameter ``junit_duration_report`` to optionally report test call durations, excluding setup and teardown times.
6780
6781 The JUnit XML specification and the default pytest behavior is to include setup and teardown times in the test duration
6782 report. You can include just the call durations instead (excluding setup and teardown) by adding this to your ``pytest.ini`` file:
6783
6784 .. code-block:: ini
6785
6786 [pytest]
6787 junit_duration_report = call
6788
6789
6790 - :issue:`4532`: ``-ra`` now will show errors and failures last, instead of as the first items in the summary.
6791
6792 This makes it easier to obtain a list of errors and failures to run tests selectively.
6793
6794
6795 - :issue:`4599`: ``pytest.importorskip`` now supports a ``reason`` parameter, which will be shown when the
6796 requested module cannot be imported.
6797
6798
6799
6800 Bug Fixes
6801 ---------
6802
6803 - :issue:`3532`: ``-p`` now accepts its argument without a space between the value, for example ``-pmyplugin``.
6804
6805
6806 - :issue:`4327`: ``approx`` again works with more generic containers, more precisely instances of ``Iterable`` and ``Sized`` instead of more restrictive ``Sequence``.
6807
6808
6809 - :issue:`4397`: Ensure that node ids are printable.
6810
6811
6812 - :issue:`4435`: Fixed ``raises(..., 'code(string)')`` frame filename.
6813
6814
6815 - :issue:`4458`: Display actual test ids in ``--collect-only``.
6816
6817
6818
6819 Improved Documentation
6820 ----------------------
6821
6822 - :issue:`4557`: Markers example documentation page updated to support latest pytest version.
6823
6824
6825 - :issue:`4558`: Update cache documentation example to correctly show cache hit and miss.
6826
6827
6828 - :issue:`4580`: Improved detailed summary report documentation.
6829
6830
6831
6832 Trivial/Internal Changes
6833 ------------------------
6834
6835 - :issue:`4447`: Changed the deprecation type of ``--result-log`` to ``PytestDeprecationWarning``.
6836
6837 It was decided to remove this feature at the next major revision.
6838
6839
6840 pytest 4.0.2 (2018-12-13)
6841 =========================
6842
6843 Bug Fixes
6844 ---------
6845
6846 - :issue:`4265`: Validate arguments from the ``PYTEST_ADDOPTS`` environment variable and the ``addopts`` ini option separately.
6847
6848
6849 - :issue:`4435`: Fix ``raises(..., 'code(string)')`` frame filename.
6850
6851
6852 - :issue:`4500`: When a fixture yields and a log call is made after the test runs, and, if the test is interrupted, capture attributes are ``None``.
6853
6854
6855 - :issue:`4538`: Raise ``TypeError`` for ``with raises(..., match=<non-None falsey value>)``.
6856
6857
6858
6859 Improved Documentation
6860 ----------------------
6861
6862 - :issue:`1495`: Document common doctest fixture directory tree structure pitfalls
6863
6864
6865 pytest 4.0.1 (2018-11-23)
6866 =========================
6867
6868 Bug Fixes
6869 ---------
6870
6871 - :issue:`3952`: Display warnings before "short test summary info" again, but still later warnings in the end.
6872
6873
6874 - :issue:`4386`: Handle uninitialized exceptioninfo in repr/str.
6875
6876
6877 - :issue:`4393`: Do not create ``.gitignore``/``README.md`` files in existing cache directories.
6878
6879
6880 - :issue:`4400`: Rearrange warning handling for the yield test errors so the opt-out in 4.0.x correctly works.
6881
6882
6883 - :issue:`4405`: Fix collection of testpaths with ``--pyargs``.
6884
6885
6886 - :issue:`4412`: Fix assertion rewriting involving ``Starred`` + side-effects.
6887
6888
6889 - :issue:`4425`: Ensure we resolve the absolute path when the given ``--basetemp`` is a relative path.
6890
6891
6892
6893 Trivial/Internal Changes
6894 ------------------------
6895
6896 - :issue:`4315`: Use ``pkg_resources.parse_version`` instead of ``LooseVersion`` in minversion check.
6897
6898
6899 - :issue:`4440`: Adjust the stack level of some internal pytest warnings.
6900
6901
6902 pytest 4.0.0 (2018-11-13)
6903 =========================
6904
6905 Removals
6906 --------
6907
6908 - :issue:`3737`: **RemovedInPytest4Warnings are now errors by default.**
6909
6910 Following our plan to remove deprecated features with as little disruption as
6911 possible, all warnings of type ``RemovedInPytest4Warnings`` now generate errors
6912 instead of warning messages.
6913
6914 **The affected features will be effectively removed in pytest 4.1**, so please consult the
6915 :std:doc:`deprecations` section in the docs for directions on how to update existing code.
6916
6917 In the pytest ``4.0.X`` series, it is possible to change the errors back into warnings as a stop
6918 gap measure by adding this to your ``pytest.ini`` file:
6919
6920 .. code-block:: ini
6921
6922 [pytest]
6923 filterwarnings =
6924 ignore::pytest.RemovedInPytest4Warning
6925
6926 But this will stop working when pytest ``4.1`` is released.
6927
6928 **If you have concerns** about the removal of a specific feature, please add a
6929 comment to :issue:`4348`.
6930
6931
6932 - :issue:`4358`: Remove the ``::()`` notation to denote a test class instance in node ids.
6933
6934 Previously, node ids that contain test instances would use ``::()`` to denote the instance like this::
6935
6936 test_foo.py::Test::()::test_bar
6937
6938 The extra ``::()`` was puzzling to most users and has been removed, so that the test id becomes now::
6939
6940 test_foo.py::Test::test_bar
6941
6942 This change could not accompany a deprecation period as is usual when user-facing functionality changes because
6943 it was not really possible to detect when the functionality was being used explicitly.
6944
6945 The extra ``::()`` might have been removed in some places internally already,
6946 which then led to confusion in places where it was expected, e.g. with
6947 ``--deselect`` (:issue:`4127`).
6948
6949 Test class instances are also not listed with ``--collect-only`` anymore.
6950
6951
6952
6953 Features
6954 --------
6955
6956 - :issue:`4270`: The ``cache_dir`` option uses ``$TOX_ENV_DIR`` as prefix (if set in the environment).
6957
6958 This uses a different cache per tox environment by default.
6959
6960
6961
6962 Bug Fixes
6963 ---------
6964
6965 - :issue:`3554`: Fix ``CallInfo.__repr__`` for when the call is not finished yet.
6966
6967
6968 pytest 3.10.1 (2018-11-11)
6969 ==========================
6970
6971 Bug Fixes
6972 ---------
6973
6974 - :issue:`4287`: Fix nested usage of debugging plugin (pdb), e.g. with pytester's ``testdir.runpytest``.
6975
6976
6977 - :issue:`4304`: Block the ``stepwise`` plugin if ``cacheprovider`` is also blocked, as one depends on the other.
6978
6979
6980 - :issue:`4306`: Parse ``minversion`` as an actual version and not as dot-separated strings.
6981
6982
6983 - :issue:`4310`: Fix duplicate collection due to multiple args matching the same packages.
6984
6985
6986 - :issue:`4321`: Fix ``item.nodeid`` with resolved symlinks.
6987
6988
6989 - :issue:`4325`: Fix collection of direct symlinked files, where the target does not match ``python_files``.
6990
6991
6992 - :issue:`4329`: Fix TypeError in report_collect with _collect_report_last_write.
6993
6994
6995
6996 Trivial/Internal Changes
6997 ------------------------
6998
6999 - :issue:`4305`: Replace byte/unicode helpers in test_capture with python level syntax.
7000
7001
7002 pytest 3.10.0 (2018-11-03)
7003 ==========================
7004
7005 Features
7006 --------
7007
7008 - :issue:`2619`: Resume capturing output after ``continue`` with ``__import__("pdb").set_trace()``.
7009
7010 This also adds a new ``pytest_leave_pdb`` hook, and passes in ``pdb`` to the
7011 existing ``pytest_enter_pdb`` hook.
7012
7013
7014 - :issue:`4147`: Add ``--sw``, ``--stepwise`` as an alternative to ``--lf -x`` for stopping at the first failure, but starting the next test invocation from that test. See :ref:`the documentation <cache stepwise>` for more info.
7015
7016
7017 - :issue:`4188`: Make ``--color`` emit colorful dots when not running in verbose mode. Earlier, it would only colorize the test-by-test output if ``--verbose`` was also passed.
7018
7019
7020 - :issue:`4225`: Improve performance with collection reporting in non-quiet mode with terminals.
7021
7022 The "collecting …" message is only printed/updated every 0.5s.
7023
7024
7025
7026 Bug Fixes
7027 ---------
7028
7029 - :issue:`2701`: Fix false ``RemovedInPytest4Warning: usage of Session... is deprecated, please use pytest`` warnings.
7030
7031
7032 - :issue:`4046`: Fix problems with running tests in package ``__init__.py`` files.
7033
7034
7035 - :issue:`4260`: Swallow warnings during anonymous compilation of source.
7036
7037
7038 - :issue:`4262`: Fix access denied error when deleting stale directories created by ``tmpdir`` / ``tmp_path``.
7039
7040
7041 - :issue:`611`: Naming a fixture ``request`` will now raise a warning: the ``request`` fixture is internal and
7042 should not be overwritten as it will lead to internal errors.
7043
7044 - :issue:`4266`: Handle (ignore) exceptions raised during collection, e.g. with Django's LazySettings proxy class.
7045
7046
7047
7048 Improved Documentation
7049 ----------------------
7050
7051 - :issue:`4255`: Added missing documentation about the fact that module names passed to filter warnings are not regex-escaped.
7052
7053
7054
7055 Trivial/Internal Changes
7056 ------------------------
7057
7058 - :issue:`4272`: Display cachedir also in non-verbose mode if non-default.
7059
7060
7061 - :issue:`4277`: pdb: improve message about output capturing with ``set_trace``.
7062
7063 Do not display "IO-capturing turned off/on" when ``-s`` is used to avoid
7064 confusion.
7065
7066
7067 - :issue:`4279`: Improve message and stack level of warnings issued by ``monkeypatch.setenv`` when the value of the environment variable is not a ``str``.
7068
7069
7070 pytest 3.9.3 (2018-10-27)
7071 =========================
7072
7073 Bug Fixes
7074 ---------
7075
7076 - :issue:`4174`: Fix "ValueError: Plugin already registered" with conftest plugins via symlink.
7077
7078
7079 - :issue:`4181`: Handle race condition between creation and deletion of temporary folders.
7080
7081
7082 - :issue:`4221`: Fix bug where the warning summary at the end of the test session was not showing the test where the warning was originated.
7083
7084
7085 - :issue:`4243`: Fix regression when ``stacklevel`` for warnings was passed as positional argument on python2.
7086
7087
7088
7089 Improved Documentation
7090 ----------------------
7091
7092 - :issue:`3851`: Add reference to ``empty_parameter_set_mark`` ini option in documentation of ``@pytest.mark.parametrize``
7093
7094
7095
7096 Trivial/Internal Changes
7097 ------------------------
7098
7099 - :issue:`4028`: Revert patching of ``sys.breakpointhook`` since it appears to do nothing.
7100
7101
7102 - :issue:`4233`: Apply an import sorter (``reorder-python-imports``) to the codebase.
7103
7104
7105 - :issue:`4248`: Remove use of unnecessary compat shim, six.binary_type
7106
7107
7108 pytest 3.9.2 (2018-10-22)
7109 =========================
7110
7111 Bug Fixes
7112 ---------
7113
7114 - :issue:`2909`: Improve error message when a recursive dependency between fixtures is detected.
7115
7116
7117 - :issue:`3340`: Fix logging messages not shown in hooks ``pytest_sessionstart()`` and ``pytest_sessionfinish()``.
7118
7119
7120 - :issue:`3533`: Fix unescaped XML raw objects in JUnit report for skipped tests
7121
7122
7123 - :issue:`3691`: Python 2: safely format warning message about passing unicode strings to ``warnings.warn``, which may cause
7124 surprising ``MemoryError`` exception when monkey patching ``warnings.warn`` itself.
7125
7126
7127 - :issue:`4026`: Improve error message when it is not possible to determine a function's signature.
7128
7129
7130 - :issue:`4177`: Pin ``setuptools>=40.0`` to support ``py_modules`` in ``setup.cfg``
7131
7132
7133 - :issue:`4179`: Restore the tmpdir behaviour of symlinking the current test run.
7134
7135
7136 - :issue:`4192`: Fix filename reported by ``warnings.warn`` when using ``recwarn`` under python2.
7137
7138
7139 pytest 3.9.1 (2018-10-16)
7140 =========================
7141
7142 Features
7143 --------
7144
7145 - :issue:`4159`: For test-suites containing test classes, the information about the subclassed
7146 module is now output only if a higher verbosity level is specified (at least
7147 "-vv").
7148
7149
7150 pytest 3.9.0 (2018-10-15 - not published due to a release automation bug)
7151 =========================================================================
7152
7153 Deprecations
7154 ------------
7155
7156 - :issue:`3616`: The following accesses have been documented as deprecated for years, but are now actually emitting deprecation warnings.
7157
7158 * Access of ``Module``, ``Function``, ``Class``, ``Instance``, ``File`` and ``Item`` through ``Node`` instances. Now
7159 users will this warning::
7160
7161 usage of Function.Module is deprecated, please use pytest.Module instead
7162
7163 Users should just ``import pytest`` and access those objects using the ``pytest`` module.
7164
7165 * ``request.cached_setup``, this was the precursor of the setup/teardown mechanism available to fixtures. You can
7166 consult :std:doc:`funcarg comparison section in the docs <funcarg_compare>`.
7167
7168 * Using objects named ``"Class"`` as a way to customize the type of nodes that are collected in ``Collector``
7169 subclasses has been deprecated. Users instead should use ``pytest_collect_make_item`` to customize node types during
7170 collection.
7171
7172 This issue should affect only advanced plugins who create new collection types, so if you see this warning
7173 message please contact the authors so they can change the code.
7174
7175 * The warning that produces the message below has changed to ``RemovedInPytest4Warning``::
7176
7177 getfuncargvalue is deprecated, use getfixturevalue
7178
7179
7180 - :issue:`3988`: Add a Deprecation warning for pytest.ensuretemp as it was deprecated since a while.
7181
7182
7183
7184 Features
7185 --------
7186
7187 - :issue:`2293`: Improve usage errors messages by hiding internal details which can be distracting and noisy.
7188
7189 This has the side effect that some error conditions that previously raised generic errors (such as
7190 ``ValueError`` for unregistered marks) are now raising ``Failed`` exceptions.
7191
7192
7193 - :issue:`3332`: Improve the error displayed when a ``conftest.py`` file could not be imported.
7194
7195 In order to implement this, a new ``chain`` parameter was added to ``ExceptionInfo.getrepr``
7196 to show or hide chained tracebacks in Python 3 (defaults to ``True``).
7197
7198
7199 - :issue:`3849`: Add ``empty_parameter_set_mark=fail_at_collect`` ini option for raising an exception when parametrize collects an empty set.
7200
7201
7202 - :issue:`3964`: Log messages generated in the collection phase are shown when
7203 live-logging is enabled and/or when they are logged to a file.
7204
7205
7206 - :issue:`3985`: Introduce ``tmp_path`` as a fixture providing a Path object. Also introduce ``tmp_path_factory`` as
7207 a session-scoped fixture for creating arbitrary temporary directories from any other fixture or test.
7208
7209
7210 - :issue:`4013`: Deprecation warnings are now shown even if you customize the warnings filters yourself. In the previous version
7211 any customization would override pytest's filters and deprecation warnings would fall back to being hidden by default.
7212
7213
7214 - :issue:`4073`: Allow specification of timeout for ``Testdir.runpytest_subprocess()`` and ``Testdir.run()``.
7215
7216
7217 - :issue:`4098`: Add returncode argument to pytest.exit() to exit pytest with a specific return code.
7218
7219
7220 - :issue:`4102`: Reimplement ``pytest.deprecated_call`` using ``pytest.warns`` so it supports the ``match='...'`` keyword argument.
7221
7222 This has the side effect that ``pytest.deprecated_call`` now raises ``pytest.fail.Exception`` instead
7223 of ``AssertionError``.
7224
7225
7226 - :issue:`4149`: Require setuptools>=30.3 and move most of the metadata to ``setup.cfg``.
7227
7228
7229
7230 Bug Fixes
7231 ---------
7232
7233 - :issue:`2535`: Improve error message when test functions of ``unittest.TestCase`` subclasses use a parametrized fixture.
7234
7235
7236 - :issue:`3057`: ``request.fixturenames`` now correctly returns the name of fixtures created by ``request.getfixturevalue()``.
7237
7238
7239 - :issue:`3946`: Warning filters passed as command line options using ``-W`` now take precedence over filters defined in ``ini``
7240 configuration files.
7241
7242
7243 - :issue:`4066`: Fix source reindenting by using ``textwrap.dedent`` directly.
7244
7245
7246 - :issue:`4102`: ``pytest.warn`` will capture previously-warned warnings in Python 2. Previously they were never raised.
7247
7248
7249 - :issue:`4108`: Resolve symbolic links for args.
7250
7251 This fixes running ``pytest tests/test_foo.py::test_bar``, where ``tests``
7252 is a symlink to ``project/app/tests``:
7253 previously ``project/app/conftest.py`` would be ignored for fixtures then.
7254
7255
7256 - :issue:`4132`: Fix duplicate printing of internal errors when using ``--pdb``.
7257
7258
7259 - :issue:`4135`: pathlib based tmpdir cleanup now correctly handles symlinks in the folder.
7260
7261
7262 - :issue:`4152`: Display the filename when encountering ``SyntaxWarning``.
7263
7264
7265
7266 Improved Documentation
7267 ----------------------
7268
7269 - :issue:`3713`: Update usefixtures documentation to clarify that it can't be used with fixture functions.
7270
7271
7272 - :issue:`4058`: Update fixture documentation to specify that a fixture can be invoked twice in the scope it's defined for.
7273
7274
7275 - :issue:`4064`: According to unittest.rst, setUpModule and tearDownModule were not implemented, but it turns out they are. So updated the documentation for unittest.
7276
7277
7278 - :issue:`4151`: Add tempir testing example to CONTRIBUTING.rst guide
7279
7280
7281
7282 Trivial/Internal Changes
7283 ------------------------
7284
7285 - :issue:`2293`: The internal ``MarkerError`` exception has been removed.
7286
7287
7288 - :issue:`3988`: Port the implementation of tmpdir to pathlib.
7289
7290
7291 - :issue:`4063`: Exclude 0.00 second entries from ``--duration`` output unless ``-vv`` is passed on the command-line.
7292
7293
7294 - :issue:`4093`: Fixed formatting of string literals in internal tests.
7295
7296
7297 pytest 3.8.2 (2018-10-02)
7298 =========================
7299
7300 Deprecations and Removals
7301 -------------------------
7302
7303 - :issue:`4036`: The ``item`` parameter of ``pytest_warning_captured`` hook is now documented as deprecated. We realized only after
7304 the ``3.8`` release that this parameter is incompatible with ``pytest-xdist``.
7305
7306 Our policy is to not deprecate features during bug-fix releases, but in this case we believe it makes sense as we are
7307 only documenting it as deprecated, without issuing warnings which might potentially break test suites. This will get
7308 the word out that hook implementers should not use this parameter at all.
7309
7310 In a future release ``item`` will always be ``None`` and will emit a proper warning when a hook implementation
7311 makes use of it.
7312
7313
7314
7315 Bug Fixes
7316 ---------
7317
7318 - :issue:`3539`: Fix reload on assertion rewritten modules.
7319
7320
7321 - :issue:`4034`: The ``.user_properties`` attribute of ``TestReport`` objects is a list
7322 of (name, value) tuples, but could sometimes be instantiated as a tuple
7323 of tuples. It is now always a list.
7324
7325
7326 - :issue:`4039`: No longer issue warnings about using ``pytest_plugins`` in non-top-level directories when using ``--pyargs``: the
7327 current ``--pyargs`` mechanism is not reliable and might give false negatives.
7328
7329
7330 - :issue:`4040`: Exclude empty reports for passed tests when ``-rP`` option is used.
7331
7332
7333 - :issue:`4051`: Improve error message when an invalid Python expression is passed to the ``-m`` option.
7334
7335
7336 - :issue:`4056`: ``MonkeyPatch.setenv`` and ``MonkeyPatch.delenv`` issue a warning if the environment variable name is not ``str`` on Python 2.
7337
7338 In Python 2, adding ``unicode`` keys to ``os.environ`` causes problems with ``subprocess`` (and possible other modules),
7339 making this a subtle bug specially susceptible when used with ``from __future__ import unicode_literals``.
7340
7341
7342
7343 Improved Documentation
7344 ----------------------
7345
7346 - :issue:`3928`: Add possible values for fixture scope to docs.
7347
7348
7349 pytest 3.8.1 (2018-09-22)
7350 =========================
7351
7352 Bug Fixes
7353 ---------
7354
7355 - :issue:`3286`: ``.pytest_cache`` directory is now automatically ignored by Git. Users who would like to contribute a solution for other SCMs please consult/comment on this issue.
7356
7357
7358 - :issue:`3749`: Fix the following error during collection of tests inside packages::
7359
7360 TypeError: object of type 'Package' has no len()
7361
7362
7363 - :issue:`3941`: Fix bug where indirect parametrization would consider the scope of all fixtures used by the test function to determine the parametrization scope, and not only the scope of the fixtures being parametrized.
7364
7365
7366 - :issue:`3973`: Fix crash of the assertion rewriter if a test changed the current working directory without restoring it afterwards.
7367
7368
7369 - :issue:`3998`: Fix issue that prevented some caplog properties (for example ``record_tuples``) from being available when entering the debugger with ``--pdb``.
7370
7371
7372 - :issue:`3999`: Fix ``UnicodeDecodeError`` in python2.x when a class returns a non-ascii binary ``__repr__`` in an assertion which also contains non-ascii text.
7373
7374
7375
7376 Improved Documentation
7377 ----------------------
7378
7379 - :issue:`3996`: New :std:doc:`deprecations` page shows all currently
7380 deprecated features, the rationale to do so, and alternatives to update your code. It also list features removed
7381 from pytest in past major releases to help those with ancient pytest versions to upgrade.
7382
7383
7384
7385 Trivial/Internal Changes
7386 ------------------------
7387
7388 - :issue:`3955`: Improve pre-commit detection for changelog filenames
7389
7390
7391 - :issue:`3975`: Remove legacy code around im_func as that was python2 only
7392
7393
7394 pytest 3.8.0 (2018-09-05)
7395 =========================
7396
7397 Deprecations and Removals
7398 -------------------------
7399
7400 - :issue:`2452`: ``Config.warn`` and ``Node.warn`` have been
7401 deprecated, see :ref:`config.warn and node.warn deprecated` for rationale and
7402 examples.
7403
7404 - :issue:`3936`: ``@pytest.mark.filterwarnings`` second parameter is no longer regex-escaped,
7405 making it possible to actually use regular expressions to check the warning message.
7406
7407 **Note**: regex-escaping the match string was an implementation oversight that might break test suites which depend
7408 on the old behavior.
7409
7410
7411
7412 Features
7413 --------
7414
7415 - :issue:`2452`: Internal pytest warnings are now issued using the standard ``warnings`` module, making it possible to use
7416 the standard warnings filters to manage those warnings. This introduces ``PytestWarning``,
7417 ``PytestDeprecationWarning`` and ``RemovedInPytest4Warning`` warning types as part of the public API.
7418
7419 Consult :ref:`the documentation <internal-warnings>` for more info.
7420
7421
7422 - :issue:`2908`: ``DeprecationWarning`` and ``PendingDeprecationWarning`` are now shown by default if no other warning filter is
7423 configured. This makes pytest more compliant with
7424 :pep:`506#recommended-filter-settings-for-test-runners`. See
7425 :ref:`the docs <deprecation-warnings>` for
7426 more info.
7427
7428
7429 - :issue:`3251`: Warnings are now captured and displayed during test collection.
7430
7431
7432 - :issue:`3784`: ``PYTEST_DISABLE_PLUGIN_AUTOLOAD`` environment variable disables plugin auto-loading when set.
7433
7434
7435 - :issue:`3829`: Added the ``count`` option to ``console_output_style`` to enable displaying the progress as a count instead of a percentage.
7436
7437
7438 - :issue:`3837`: Added support for 'xfailed' and 'xpassed' outcomes to the ``pytester.RunResult.assert_outcomes`` signature.
7439
7440
7441
7442 Bug Fixes
7443 ---------
7444
7445 - :issue:`3911`: Terminal writer now takes into account unicode character width when writing out progress.
7446
7447
7448 - :issue:`3913`: Pytest now returns with correct exit code (EXIT_USAGEERROR, 4) when called with unknown arguments.
7449
7450
7451 - :issue:`3918`: Improve performance of assertion rewriting.
7452
7453
7454
7455 Improved Documentation
7456 ----------------------
7457
7458 - :issue:`3566`: Added a blurb in usage.rst for the usage of -r flag which is used to show an extra test summary info.
7459
7460
7461 - :issue:`3907`: Corrected type of the exceptions collection passed to ``xfail``: ``raises`` argument accepts a ``tuple`` instead of ``list``.
7462
7463
7464
7465 Trivial/Internal Changes
7466 ------------------------
7467
7468 - :issue:`3853`: Removed ``"run all (no recorded failures)"`` message printed with ``--failed-first`` and ``--last-failed`` when there are no failed tests.
7469
7470
7471 pytest 3.7.4 (2018-08-29)
7472 =========================
7473
7474 Bug Fixes
7475 ---------
7476
7477 - :issue:`3506`: Fix possible infinite recursion when writing ``.pyc`` files.
7478
7479
7480 - :issue:`3853`: Cache plugin now obeys the ``-q`` flag when ``--last-failed`` and ``--failed-first`` flags are used.
7481
7482
7483 - :issue:`3883`: Fix bad console output when using ``console_output_style=classic``.
7484
7485
7486 - :issue:`3888`: Fix macOS specific code using ``capturemanager`` plugin in doctests.
7487
7488
7489
7490 Improved Documentation
7491 ----------------------
7492
7493 - :issue:`3902`: Fix pytest.org links
7494
7495
7496 pytest 3.7.3 (2018-08-26)
7497 =========================
7498
7499 Bug Fixes
7500 ---------
7501
7502 - :issue:`3033`: Fixtures during teardown can again use ``capsys`` and ``capfd`` to inspect output captured during tests.
7503
7504
7505 - :issue:`3773`: Fix collection of tests from ``__init__.py`` files if they match the ``python_files`` configuration option.
7506
7507
7508 - :issue:`3796`: Fix issue where teardown of fixtures of consecutive sub-packages were executed once, at the end of the outer
7509 package.
7510
7511
7512 - :issue:`3816`: Fix bug where ``--show-capture=no`` option would still show logs printed during fixture teardown.
7513
7514
7515 - :issue:`3819`: Fix ``stdout/stderr`` not getting captured when real-time cli logging is active.
7516
7517
7518 - :issue:`3843`: Fix collection error when specifying test functions directly in the command line using ``test.py::test`` syntax together with ``--doctest-modules``.
7519
7520
7521 - :issue:`3848`: Fix bugs where unicode arguments could not be passed to ``testdir.runpytest`` on Python 2.
7522
7523
7524 - :issue:`3854`: Fix double collection of tests within packages when the filename starts with a capital letter.
7525
7526
7527
7528 Improved Documentation
7529 ----------------------
7530
7531 - :issue:`3824`: Added example for multiple glob pattern matches in ``python_files``.
7532
7533
7534 - :issue:`3833`: Added missing docs for ``pytester.Testdir``.
7535
7536
7537 - :issue:`3870`: Correct documentation for setuptools integration.
7538
7539
7540
7541 Trivial/Internal Changes
7542 ------------------------
7543
7544 - :issue:`3826`: Replace broken type annotations with type comments.
7545
7546
7547 - :issue:`3845`: Remove a reference to issue :issue:`568` from the documentation, which has since been
7548 fixed.
7549
7550
7551 pytest 3.7.2 (2018-08-16)
7552 =========================
7553
7554 Bug Fixes
7555 ---------
7556
7557 - :issue:`3671`: Fix ``filterwarnings`` not being registered as a builtin mark.
7558
7559
7560 - :issue:`3768`, :issue:`3789`: Fix test collection from packages mixed with normal directories.
7561
7562
7563 - :issue:`3771`: Fix infinite recursion during collection if a ``pytest_ignore_collect`` hook returns ``False`` instead of ``None``.
7564
7565
7566 - :issue:`3774`: Fix bug where decorated fixtures would lose functionality (for example ``@mock.patch``).
7567
7568
7569 - :issue:`3775`: Fix bug where importing modules or other objects with prefix ``pytest_`` prefix would raise a ``PluginValidationError``.
7570
7571
7572 - :issue:`3788`: Fix ``AttributeError`` during teardown of ``TestCase`` subclasses which raise an exception during ``__init__``.
7573
7574
7575 - :issue:`3804`: Fix traceback reporting for exceptions with ``__cause__`` cycles.
7576
7577
7578
7579 Improved Documentation
7580 ----------------------
7581
7582 - :issue:`3746`: Add documentation for ``metafunc.config`` that had been mistakenly hidden.
7583
7584
7585 pytest 3.7.1 (2018-08-02)
7586 =========================
7587
7588 Bug Fixes
7589 ---------
7590
7591 - :issue:`3473`: Raise immediately if ``approx()`` is given an expected value of a type it doesn't understand (e.g. strings, nested dicts, etc.).
7592
7593
7594 - :issue:`3712`: Correctly represent the dimensions of a numpy array when calling ``repr()`` on ``approx()``.
7595
7596 - :issue:`3742`: Fix incompatibility with third party plugins during collection, which produced the error ``object has no attribute '_collectfile'``.
7597
7598 - :issue:`3745`: Display the absolute path if ``cache_dir`` is not relative to the ``rootdir`` instead of failing.
7599
7600
7601 - :issue:`3747`: Fix compatibility problem with plugins and the warning code issued by fixture functions when they are called directly.
7602
7603
7604 - :issue:`3748`: Fix infinite recursion in ``pytest.approx`` with arrays in ``numpy<1.13``.
7605
7606
7607 - :issue:`3757`: Pin pathlib2 to ``>=2.2.0`` as we require ``__fspath__`` support.
7608
7609
7610 - :issue:`3763`: Fix ``TypeError`` when the assertion message is ``bytes`` in python 3.
7611
7612
7613 pytest 3.7.0 (2018-07-30)
7614 =========================
7615
7616 Deprecations and Removals
7617 -------------------------
7618
7619 - :issue:`2639`: ``pytest_namespace`` has been :ref:`deprecated <pytest.namespace deprecated>`.
7620
7621
7622 - :issue:`3661`: Calling a fixture function directly, as opposed to request them in a test function, now issues a ``RemovedInPytest4Warning``. See :ref:`the documentation for rationale and examples <calling fixtures directly deprecated>`.
7623
7624
7625
7626 Features
7627 --------
7628
7629 - :issue:`2283`: New ``package`` fixture scope: fixtures are finalized when the last test of a *package* finishes. This feature is considered **experimental**, so use it sparingly.
7630
7631
7632 - :issue:`3576`: ``Node.add_marker`` now supports an ``append=True/False`` parameter to determine whether the mark comes last (default) or first.
7633
7634
7635 - :issue:`3579`: Fixture ``caplog`` now has a ``messages`` property, providing convenient access to the format-interpolated log messages without the extra data provided by the formatter/handler.
7636
7637
7638 - :issue:`3610`: New ``--trace`` option to enter the debugger at the start of a test.
7639
7640
7641 - :issue:`3623`: Introduce ``pytester.copy_example`` as helper to do acceptance tests against examples from the project.
7642
7643
7644
7645 Bug Fixes
7646 ---------
7647
7648 - :issue:`2220`: Fix a bug where fixtures overridden by direct parameters (for example parametrization) were being instantiated even if they were not being used by a test.
7649
7650
7651 - :issue:`3695`: Fix ``ApproxNumpy`` initialisation argument mixup, ``abs`` and ``rel`` tolerances were flipped causing strange comparison results.
7652 Add tests to check ``abs`` and ``rel`` tolerances for ``np.array`` and test for expecting ``nan`` with ``np.array()``
7653
7654
7655 - :issue:`980`: Fix truncated locals output in verbose mode.
7656
7657
7658
7659 Improved Documentation
7660 ----------------------
7661
7662 - :issue:`3295`: Correct the usage documentation of ``--last-failed-no-failures`` by adding the missing ``--last-failed`` argument in the presented examples, because they are misleading and lead to think that the missing argument is not needed.
7663
7664
7665
7666 Trivial/Internal Changes
7667 ------------------------
7668
7669 - :issue:`3519`: Now a ``README.md`` file is created in ``.pytest_cache`` to make it clear why the directory exists.
7670
7671
7672 pytest 3.6.4 (2018-07-28)
7673 =========================
7674
7675 Bug Fixes
7676 ---------
7677
7678 - Invoke pytest using ``-mpytest`` so ``sys.path`` does not get polluted by packages installed in ``site-packages``. (:issue:`742`)
7679
7680
7681 Improved Documentation
7682 ----------------------
7683
7684 - Use ``smtp_connection`` instead of ``smtp`` in fixtures documentation to avoid possible confusion. (:issue:`3592`)
7685
7686
7687 Trivial/Internal Changes
7688 ------------------------
7689
7690 - Remove obsolete ``__future__`` imports. (:issue:`2319`)
7691
7692 - Add CITATION to provide information on how to formally cite pytest. (:issue:`3402`)
7693
7694 - Replace broken type annotations with type comments. (:issue:`3635`)
7695
7696 - Pin ``pluggy`` to ``<0.8``. (:issue:`3727`)
7697
7698
7699 pytest 3.6.3 (2018-07-04)
7700 =========================
7701
7702 Bug Fixes
7703 ---------
7704
7705 - Fix ``ImportWarning`` triggered by explicit relative imports in
7706 assertion-rewritten package modules. (:issue:`3061`)
7707
7708 - Fix error in ``pytest.approx`` when dealing with 0-dimension numpy
7709 arrays. (:issue:`3593`)
7710
7711 - No longer raise ``ValueError`` when using the ``get_marker`` API. (:issue:`3605`)
7712
7713 - Fix problem where log messages with non-ascii characters would not
7714 appear in the output log file.
7715 (:issue:`3630`)
7716
7717 - No longer raise ``AttributeError`` when legacy marks can't be stored in
7718 functions. (:issue:`3631`)
7719
7720
7721 Improved Documentation
7722 ----------------------
7723
7724 - The description above the example for ``@pytest.mark.skipif`` now better
7725 matches the code. (:issue:`3611`)
7726
7727
7728 Trivial/Internal Changes
7729 ------------------------
7730
7731 - Internal refactoring: removed unused ``CallSpec2tox ._globalid_args``
7732 attribute and ``metafunc`` parameter from ``CallSpec2.copy()``. (:issue:`3598`)
7733
7734 - Silence usage of ``reduce`` warning in Python 2 (:issue:`3609`)
7735
7736 - Fix usage of ``attr.ib`` deprecated ``convert`` parameter. (:issue:`3653`)
7737
7738
7739 pytest 3.6.2 (2018-06-20)
7740 =========================
7741
7742 Bug Fixes
7743 ---------
7744
7745 - Fix regression in ``Node.add_marker`` by extracting the mark object of a
7746 ``MarkDecorator``. (:issue:`3555`)
7747
7748 - Warnings without ``location`` were reported as ``None``. This is corrected to
7749 now report ``<undetermined location>``. (:issue:`3563`)
7750
7751 - Continue to call finalizers in the stack when a finalizer in a former scope
7752 raises an exception. (:issue:`3569`)
7753
7754 - Fix encoding error with ``print`` statements in doctests (:issue:`3583`)
7755
7756
7757 Improved Documentation
7758 ----------------------
7759
7760 - Add documentation for the ``--strict`` flag. (:issue:`3549`)
7761
7762
7763 Trivial/Internal Changes
7764 ------------------------
7765
7766 - Update old quotation style to parens in fixture.rst documentation. (:issue:`3525`)
7767
7768 - Improve display of hint about ``--fulltrace`` with ``KeyboardInterrupt``.
7769 (:issue:`3545`)
7770
7771 - pytest's testsuite is no longer runnable through ``python setup.py test`` --
7772 instead invoke ``pytest`` or ``tox`` directly. (:issue:`3552`)
7773
7774 - Fix typo in documentation (:issue:`3567`)
7775
7776
7777 pytest 3.6.1 (2018-06-05)
7778 =========================
7779
7780 Bug Fixes
7781 ---------
7782
7783 - Fixed a bug where stdout and stderr were logged twice by junitxml when a test
7784 was marked xfail. (:issue:`3491`)
7785
7786 - Fix ``usefixtures`` mark applied to unittest tests by correctly instantiating
7787 ``FixtureInfo``. (:issue:`3498`)
7788
7789 - Fix assertion rewriter compatibility with libraries that monkey patch
7790 ``file`` objects. (:issue:`3503`)
7791
7792
7793 Improved Documentation
7794 ----------------------
7795
7796 - Added a section on how to use fixtures as factories to the fixture
7797 documentation. (:issue:`3461`)
7798
7799
7800 Trivial/Internal Changes
7801 ------------------------
7802
7803 - Enable caching for pip/pre-commit in order to reduce build time on
7804 travis/appveyor. (:issue:`3502`)
7805
7806 - Switch pytest to the src/ layout as we already suggested it for good practice
7807 - now we implement it as well. (:issue:`3513`)
7808
7809 - Fix if in tests to support 3.7.0b5, where a docstring handling in AST got
7810 reverted. (:issue:`3530`)
7811
7812 - Remove some python2.5 compatibility code. (:issue:`3529`)
7813
7814
7815 pytest 3.6.0 (2018-05-23)
7816 =========================
7817
7818 Features
7819 --------
7820
7821 - Revamp the internals of the ``pytest.mark`` implementation with correct per
7822 node handling which fixes a number of long standing bugs caused by the old
7823 design. This introduces new ``Node.iter_markers(name)`` and
7824 ``Node.get_closest_marker(name)`` APIs. Users are **strongly encouraged** to
7825 read the :ref:`reasons for the revamp in the docs <marker-revamp>`,
7826 or jump over to details about :ref:`updating existing code to use the new APIs
7827 <update marker code>`.
7828 (:issue:`3317`)
7829
7830 - Now when ``@pytest.fixture`` is applied more than once to the same function a
7831 ``ValueError`` is raised. This buggy behavior would cause surprising problems
7832 and if was working for a test suite it was mostly by accident. (:issue:`2334`)
7833
7834 - Support for Python 3.7's builtin ``breakpoint()`` method, see
7835 :ref:`Using the builtin breakpoint function <breakpoint-builtin>` for
7836 details. (:issue:`3180`)
7837
7838 - ``monkeypatch`` now supports a ``context()`` function which acts as a context
7839 manager which undoes all patching done within the ``with`` block. (:issue:`3290`)
7840
7841 - The ``--pdb`` option now causes KeyboardInterrupt to enter the debugger,
7842 instead of stopping the test session. On python 2.7, hitting CTRL+C again
7843 exits the debugger. On python 3.2 and higher, use CTRL+D. (:issue:`3299`)
7844
7845 - pytest no longer changes the log level of the root logger when the
7846 ``log-level`` parameter has greater numeric value than that of the level of
7847 the root logger, which makes it play better with custom logging configuration
7848 in user code. (:issue:`3307`)
7849
7850
7851 Bug Fixes
7852 ---------
7853
7854 - A rare race-condition which might result in corrupted ``.pyc`` files on
7855 Windows has been hopefully solved. (:issue:`3008`)
7856
7857 - Also use iter_marker for discovering the marks applying for marker
7858 expressions from the cli to avoid the bad data from the legacy mark storage.
7859 (:issue:`3441`)
7860
7861 - When showing diffs of failed assertions where the contents contain only
7862 whitespace, escape them using ``repr()`` first to make it easy to spot the
7863 differences. (:issue:`3443`)
7864
7865
7866 Improved Documentation
7867 ----------------------
7868
7869 - Change documentation copyright year to a range which auto-updates itself each
7870 time it is published. (:issue:`3303`)
7871
7872
7873 Trivial/Internal Changes
7874 ------------------------
7875
7876 - ``pytest`` now depends on the `python-atomicwrites
7877 <https://github.com/untitaker/python-atomicwrites>`_ library. (:issue:`3008`)
7878
7879 - Update all pypi.python.org URLs to pypi.org. (:issue:`3431`)
7880
7881 - Detect `pytest_` prefixed hooks using the internal plugin manager since
7882 ``pluggy`` is deprecating the ``implprefix`` argument to ``PluginManager``.
7883 (:issue:`3487`)
7884
7885 - Import ``Mapping`` and ``Sequence`` from ``_pytest.compat`` instead of
7886 directly from ``collections`` in ``python_api.py::approx``. Add ``Mapping``
7887 to ``_pytest.compat``, import it from ``collections`` on python 2, but from
7888 ``collections.abc`` on Python 3 to avoid a ``DeprecationWarning`` on Python
7889 3.7 or newer. (:issue:`3497`)
7890
7891
7892 pytest 3.5.1 (2018-04-23)
7893 =========================
7894
7895
7896 Bug Fixes
7897 ---------
7898
7899 - Reset ``sys.last_type``, ``sys.last_value`` and ``sys.last_traceback`` before
7900 each test executes. Those attributes are added by pytest during the test run
7901 to aid debugging, but were never reset so they would create a leaking
7902 reference to the last failing test's frame which in turn could never be
7903 reclaimed by the garbage collector. (:issue:`2798`)
7904
7905 - ``pytest.raises`` now raises ``TypeError`` when receiving an unknown keyword
7906 argument. (:issue:`3348`)
7907
7908 - ``pytest.raises`` now works with exception classes that look like iterables.
7909 (:issue:`3372`)
7910
7911
7912 Improved Documentation
7913 ----------------------
7914
7915 - Fix typo in ``caplog`` fixture documentation, which incorrectly identified
7916 certain attributes as methods. (:issue:`3406`)
7917
7918
7919 Trivial/Internal Changes
7920 ------------------------
7921
7922 - Added a more indicative error message when parametrizing a function whose
7923 argument takes a default value. (:issue:`3221`)
7924
7925 - Remove internal ``_pytest.terminal.flatten`` function in favor of
7926 ``more_itertools.collapse``. (:issue:`3330`)
7927
7928 - Import some modules from ``collections.abc`` instead of ``collections`` as
7929 the former modules trigger ``DeprecationWarning`` in Python 3.7. (:issue:`3339`)
7930
7931 - record_property is no longer experimental, removing the warnings was
7932 forgotten. (:issue:`3360`)
7933
7934 - Mention in documentation and CLI help that fixtures with leading ``_`` are
7935 printed by ``pytest --fixtures`` only if the ``-v`` option is added. (:issue:`3398`)
7936
7937
7938 pytest 3.5.0 (2018-03-21)
7939 =========================
7940
7941 Deprecations and Removals
7942 -------------------------
7943
7944 - ``record_xml_property`` fixture is now deprecated in favor of the more
7945 generic ``record_property``. (:issue:`2770`)
7946
7947 - Defining ``pytest_plugins`` is now deprecated in non-top-level conftest.py
7948 files, because they "leak" to the entire directory tree.
7949 :ref:`See the docs <pytest_plugins in non-top-level conftest files deprecated>`
7950 for the rationale behind this decision (:issue:`3084`)
7951
7952
7953 Features
7954 --------
7955
7956 - New ``--show-capture`` command-line option that allows to specify how to
7957 display captured output when tests fail: ``no``, ``stdout``, ``stderr``,
7958 ``log`` or ``all`` (the default). (:issue:`1478`)
7959
7960 - New ``--rootdir`` command-line option to override the rules for discovering
7961 the root directory. See :doc:`customize <reference/customize>` in the documentation for
7962 details. (:issue:`1642`)
7963
7964 - Fixtures are now instantiated based on their scopes, with higher-scoped
7965 fixtures (such as ``session``) being instantiated first than lower-scoped
7966 fixtures (such as ``function``). The relative order of fixtures of the same
7967 scope is kept unchanged, based in their declaration order and their
7968 dependencies. (:issue:`2405`)
7969
7970 - ``record_xml_property`` renamed to ``record_property`` and is now compatible
7971 with xdist, markers and any reporter. ``record_xml_property`` name is now
7972 deprecated. (:issue:`2770`)
7973
7974 - New ``--nf``, ``--new-first`` options: run new tests first followed by the
7975 rest of the tests, in both cases tests are also sorted by the file modified
7976 time, with more recent files coming first. (:issue:`3034`)
7977
7978 - New ``--last-failed-no-failures`` command-line option that allows to specify
7979 the behavior of the cache plugin's ```--last-failed`` feature when no tests
7980 failed in the last run (or no cache was found): ``none`` or ``all`` (the
7981 default). (:issue:`3139`)
7982
7983 - New ``--doctest-continue-on-failure`` command-line option to enable doctests
7984 to show multiple failures for each snippet, instead of stopping at the first
7985 failure. (:issue:`3149`)
7986
7987 - Captured log messages are added to the ``<system-out>`` tag in the generated
7988 junit xml file if the ``junit_logging`` ini option is set to ``system-out``.
7989 If the value of this ini option is ``system-err``, the logs are written to
7990 ``<system-err>``. The default value for ``junit_logging`` is ``no``, meaning
7991 captured logs are not written to the output file. (:issue:`3156`)
7992
7993 - Allow the logging plugin to handle ``pytest_runtest_logstart`` and
7994 ``pytest_runtest_logfinish`` hooks when live logs are enabled. (:issue:`3189`)
7995
7996 - Passing ``--log-cli-level`` in the command-line now automatically activates
7997 live logging. (:issue:`3190`)
7998
7999 - Add command line option ``--deselect`` to allow deselection of individual
8000 tests at collection time. (:issue:`3198`)
8001
8002 - Captured logs are printed before entering pdb. (:issue:`3204`)
8003
8004 - Deselected item count is now shown before tests are run, e.g. ``collected X
8005 items / Y deselected``. (:issue:`3213`)
8006
8007 - The builtin module ``platform`` is now available for use in expressions in
8008 ``pytest.mark``. (:issue:`3236`)
8009
8010 - The *short test summary info* section now is displayed after tracebacks and
8011 warnings in the terminal. (:issue:`3255`)
8012
8013 - New ``--verbosity`` flag to set verbosity level explicitly. (:issue:`3296`)
8014
8015 - ``pytest.approx`` now accepts comparing a numpy array with a scalar. (:issue:`3312`)
8016
8017
8018 Bug Fixes
8019 ---------
8020
8021 - Suppress ``IOError`` when closing the temporary file used for capturing
8022 streams in Python 2.7. (:issue:`2370`)
8023
8024 - Fixed ``clear()`` method on ``caplog`` fixture which cleared ``records``, but
8025 not the ``text`` property. (:issue:`3297`)
8026
8027 - During test collection, when stdin is not allowed to be read, the
8028 ``DontReadFromStdin`` object still allow itself to be iterable and resolved
8029 to an iterator without crashing. (:issue:`3314`)
8030
8031
8032 Improved Documentation
8033 ----------------------
8034
8035 - Added a :doc:`reference <reference/reference>` page
8036 to the docs. (:issue:`1713`)
8037
8038
8039 Trivial/Internal Changes
8040 ------------------------
8041
8042 - Change minimum requirement of ``attrs`` to ``17.4.0``. (:issue:`3228`)
8043
8044 - Renamed example directories so all tests pass when ran from the base
8045 directory. (:issue:`3245`)
8046
8047 - Internal ``mark.py`` module has been turned into a package. (:issue:`3250`)
8048
8049 - ``pytest`` now depends on the `more-itertools
8050 <https://github.com/erikrose/more-itertools>`_ package. (:issue:`3265`)
8051
8052 - Added warning when ``[pytest]`` section is used in a ``.cfg`` file passed
8053 with ``-c`` (:issue:`3268`)
8054
8055 - ``nodeids`` can now be passed explicitly to ``FSCollector`` and ``Node``
8056 constructors. (:issue:`3291`)
8057
8058 - Internal refactoring of ``FormattedExcinfo`` to use ``attrs`` facilities and
8059 remove old support code for legacy Python versions. (:issue:`3292`)
8060
8061 - Refactoring to unify how verbosity is handled internally. (:issue:`3296`)
8062
8063 - Internal refactoring to better integrate with argparse. (:issue:`3304`)
8064
8065 - Fix a python example when calling a fixture in doc/en/usage.rst (:issue:`3308`)
8066
8067
8068 pytest 3.4.2 (2018-03-04)
8069 =========================
8070
8071 Bug Fixes
8072 ---------
8073
8074 - Removed progress information when capture option is ``no``. (:issue:`3203`)
8075
8076 - Refactor check of bindir from ``exists`` to ``isdir``. (:issue:`3241`)
8077
8078 - Fix ``TypeError`` issue when using ``approx`` with a ``Decimal`` value.
8079 (:issue:`3247`)
8080
8081 - Fix reference cycle generated when using the ``request`` fixture. (:issue:`3249`)
8082
8083 - ``[tool:pytest]`` sections in ``*.cfg`` files passed by the ``-c`` option are
8084 now properly recognized. (:issue:`3260`)
8085
8086
8087 Improved Documentation
8088 ----------------------
8089
8090 - Add logging plugin to plugins list. (:issue:`3209`)
8091
8092
8093 Trivial/Internal Changes
8094 ------------------------
8095
8096 - Fix minor typo in fixture.rst (:issue:`3259`)
8097
8098
8099 pytest 3.4.1 (2018-02-20)
8100 =========================
8101
8102 Bug Fixes
8103 ---------
8104
8105 - Move import of ``doctest.UnexpectedException`` to top-level to avoid possible
8106 errors when using ``--pdb``. (:issue:`1810`)
8107
8108 - Added printing of captured stdout/stderr before entering pdb, and improved a
8109 test which was giving false negatives about output capturing. (:issue:`3052`)
8110
8111 - Fix ordering of tests using parametrized fixtures which can lead to fixtures
8112 being created more than necessary. (:issue:`3161`)
8113
8114 - Fix bug where logging happening at hooks outside of "test run" hooks would
8115 cause an internal error. (:issue:`3184`)
8116
8117 - Detect arguments injected by ``unittest.mock.patch`` decorator correctly when
8118 pypi ``mock.patch`` is installed and imported. (:issue:`3206`)
8119
8120 - Errors shown when a ``pytest.raises()`` with ``match=`` fails are now cleaner
8121 on what happened: When no exception was raised, the "matching '...'" part got
8122 removed as it falsely implies that an exception was raised but it didn't
8123 match. When a wrong exception was raised, it's now thrown (like
8124 ``pytest.raised()`` without ``match=`` would) instead of complaining about
8125 the unmatched text. (:issue:`3222`)
8126
8127 - Fixed output capture handling in doctests on macOS. (:issue:`985`)
8128
8129
8130 Improved Documentation
8131 ----------------------
8132
8133 - Add Sphinx parameter docs for ``match`` and ``message`` args to
8134 ``pytest.raises``. (:issue:`3202`)
8135
8136
8137 Trivial/Internal Changes
8138 ------------------------
8139
8140 - pytest has changed the publication procedure and is now being published to
8141 PyPI directly from Travis. (:issue:`3060`)
8142
8143 - Rename ``ParameterSet._for_parameterize()`` to ``_for_parametrize()`` in
8144 order to comply with the naming convention. (:issue:`3166`)
8145
8146 - Skip failing pdb/doctest test on mac. (:issue:`985`)
8147
8148
8149 pytest 3.4.0 (2018-01-30)
8150 =========================
8151
8152 Deprecations and Removals
8153 -------------------------
8154
8155 - All pytest classes now subclass ``object`` for better Python 2/3 compatibility.
8156 This should not affect user code except in very rare edge cases. (:issue:`2147`)
8157
8158
8159 Features
8160 --------
8161
8162 - Introduce ``empty_parameter_set_mark`` ini option to select which mark to
8163 apply when ``@pytest.mark.parametrize`` is given an empty set of parameters.
8164 Valid options are ``skip`` (default) and ``xfail``. Note that it is planned
8165 to change the default to ``xfail`` in future releases as this is considered
8166 less error prone. (:issue:`2527`)
8167
8168 - **Incompatible change**: after community feedback the :doc:`logging <how-to/logging>` functionality has
8169 undergone some changes. Please consult the :ref:`logging documentation <log_changes_3_4>`
8170 for details. (:issue:`3013`)
8171
8172 - Console output falls back to "classic" mode when capturing is disabled (``-s``),
8173 otherwise the output gets garbled to the point of being useless. (:issue:`3038`)
8174
8175 - New :hook:`pytest_runtest_logfinish`
8176 hook which is called when a test item has finished executing, analogous to
8177 :hook:`pytest_runtest_logstart`.
8178 (:issue:`3101`)
8179
8180 - Improve performance when collecting tests using many fixtures. (:issue:`3107`)
8181
8182 - New ``caplog.get_records(when)`` method which provides access to the captured
8183 records for the ``"setup"``, ``"call"`` and ``"teardown"``
8184 testing stages. (:issue:`3117`)
8185
8186 - New fixture ``record_xml_attribute`` that allows modifying and inserting
8187 attributes on the ``<testcase>`` xml node in JUnit reports. (:issue:`3130`)
8188
8189 - The default cache directory has been renamed from ``.cache`` to
8190 ``.pytest_cache`` after community feedback that the name ``.cache`` did not
8191 make it clear that it was used by pytest. (:issue:`3138`)
8192
8193 - Colorize the levelname column in the live-log output. (:issue:`3142`)
8194
8195
8196 Bug Fixes
8197 ---------
8198
8199 - Fix hanging pexpect test on macOS by using flush() instead of wait().
8200 (:issue:`2022`)
8201
8202 - Fix restoring Python state after in-process pytest runs with the
8203 ``pytester`` plugin; this may break tests using multiple inprocess
8204 pytest runs if later ones depend on earlier ones leaking global interpreter
8205 changes. (:issue:`3016`)
8206
8207 - Fix skipping plugin reporting hook when test aborted before plugin setup
8208 hook. (:issue:`3074`)
8209
8210 - Fix progress percentage reported when tests fail during teardown. (:issue:`3088`)
8211
8212 - **Incompatible change**: ``-o/--override`` option no longer eats all the
8213 remaining options, which can lead to surprising behavior: for example,
8214 ``pytest -o foo=1 /path/to/test.py`` would fail because ``/path/to/test.py``
8215 would be considered as part of the ``-o`` command-line argument. One
8216 consequence of this is that now multiple configuration overrides need
8217 multiple ``-o`` flags: ``pytest -o foo=1 -o bar=2``. (:issue:`3103`)
8218
8219
8220 Improved Documentation
8221 ----------------------
8222
8223 - Document hooks (defined with ``historic=True``) which cannot be used with
8224 ``hookwrapper=True``. (:issue:`2423`)
8225
8226 - Clarify that warning capturing doesn't change the warning filter by default.
8227 (:issue:`2457`)
8228
8229 - Clarify a possible confusion when using pytest_fixture_setup with fixture
8230 functions that return None. (:issue:`2698`)
8231
8232 - Fix the wording of a sentence on doctest flags used in pytest. (:issue:`3076`)
8233
8234 - Prefer ``https://*.readthedocs.io`` over ``http://*.rtfd.org`` for links in
8235 the documentation. (:issue:`3092`)
8236
8237 - Improve readability (wording, grammar) of Getting Started guide (:issue:`3131`)
8238
8239 - Added note that calling pytest.main multiple times from the same process is
8240 not recommended because of import caching. (:issue:`3143`)
8241
8242
8243 Trivial/Internal Changes
8244 ------------------------
8245
8246 - Show a simple and easy error when keyword expressions trigger a syntax error
8247 (for example, ``"-k foo and import"`` will show an error that you cannot use
8248 the ``import`` keyword in expressions). (:issue:`2953`)
8249
8250 - Change parametrized automatic test id generation to use the ``__name__``
8251 attribute of functions instead of the fallback argument name plus counter.
8252 (:issue:`2976`)
8253
8254 - Replace py.std with stdlib imports. (:issue:`3067`)
8255
8256 - Corrected 'you' to 'your' in logging docs. (:issue:`3129`)
8257
8258
8259 pytest 3.3.2 (2017-12-25)
8260 =========================
8261
8262 Bug Fixes
8263 ---------
8264
8265 - pytester: ignore files used to obtain current user metadata in the fd leak
8266 detector. (:issue:`2784`)
8267
8268 - Fix **memory leak** where objects returned by fixtures were never destructed
8269 by the garbage collector. (:issue:`2981`)
8270
8271 - Fix conversion of pyargs to filename to not convert symlinks on Python 2. (:issue:`2985`)
8272
8273 - ``PYTEST_DONT_REWRITE`` is now checked for plugins too rather than only for
8274 test modules. (:issue:`2995`)
8275
8276
8277 Improved Documentation
8278 ----------------------
8279
8280 - Add clarifying note about behavior of multiple parametrized arguments (:issue:`3001`)
8281
8282
8283 Trivial/Internal Changes
8284 ------------------------
8285
8286 - Code cleanup. (:issue:`3015`,
8287 :issue:`3021`)
8288
8289 - Clean up code by replacing imports and references of ``_ast`` to ``ast``.
8290 (:issue:`3018`)
8291
8292
8293 pytest 3.3.1 (2017-12-05)
8294 =========================
8295
8296 Bug Fixes
8297 ---------
8298
8299 - Fix issue about ``-p no:<plugin>`` having no effect. (:issue:`2920`)
8300
8301 - Fix regression with warnings that contained non-strings in their arguments in
8302 Python 2. (:issue:`2956`)
8303
8304 - Always escape null bytes when setting ``PYTEST_CURRENT_TEST``. (:issue:`2957`)
8305
8306 - Fix ``ZeroDivisionError`` when using the ``testmon`` plugin when no tests
8307 were actually collected. (:issue:`2971`)
8308
8309 - Bring back ``TerminalReporter.writer`` as an alias to
8310 ``TerminalReporter._tw``. This alias was removed by accident in the ``3.3.0``
8311 release. (:issue:`2984`)
8312
8313 - The ``pytest-capturelog`` plugin is now also blacklisted, avoiding errors when
8314 running pytest with it still installed. (:issue:`3004`)
8315
8316
8317 Improved Documentation
8318 ----------------------
8319
8320 - Fix broken link to plugin ``pytest-localserver``. (:issue:`2963`)
8321
8322
8323 Trivial/Internal Changes
8324 ------------------------
8325
8326 - Update github "bugs" link in ``CONTRIBUTING.rst`` (:issue:`2949`)
8327
8328
8329 pytest 3.3.0 (2017-11-23)
8330 =========================
8331
8332 Deprecations and Removals
8333 -------------------------
8334
8335 - pytest no longer supports Python **2.6** and **3.3**. Those Python versions
8336 are EOL for some time now and incur maintenance and compatibility costs on
8337 the pytest core team, and following up with the rest of the community we
8338 decided that they will no longer be supported starting on this version. Users
8339 which still require those versions should pin pytest to ``<3.3``. (:issue:`2812`)
8340
8341 - Remove internal ``_preloadplugins()`` function. This removal is part of the
8342 ``pytest_namespace()`` hook deprecation. (:issue:`2636`)
8343
8344 - Internally change ``CallSpec2`` to have a list of marks instead of a broken
8345 mapping of keywords. This removes the keywords attribute of the internal
8346 ``CallSpec2`` class. (:issue:`2672`)
8347
8348 - Remove ParameterSet.deprecated_arg_dict - its not a public api and the lack
8349 of the underscore was a naming error. (:issue:`2675`)
8350
8351 - Remove the internal multi-typed attribute ``Node._evalskip`` and replace it
8352 with the boolean ``Node._skipped_by_mark``. (:issue:`2767`)
8353
8354 - The ``params`` list passed to ``pytest.fixture`` is now for
8355 all effects considered immutable and frozen at the moment of the ``pytest.fixture``
8356 call. Previously the list could be changed before the first invocation of the fixture
8357 allowing for a form of dynamic parametrization (for example, updated from command-line options),
8358 but this was an unwanted implementation detail which complicated the internals and prevented
8359 some internal cleanup. See issue :issue:`2959`
8360 for details and a recommended workaround.
8361
8362 Features
8363 --------
8364
8365 - ``pytest_fixture_post_finalizer`` hook can now receive a ``request``
8366 argument. (:issue:`2124`)
8367
8368 - Replace the old introspection code in compat.py that determines the available
8369 arguments of fixtures with inspect.signature on Python 3 and
8370 funcsigs.signature on Python 2. This should respect ``__signature__``
8371 declarations on functions. (:issue:`2267`)
8372
8373 - Report tests with global ``pytestmark`` variable only once. (:issue:`2549`)
8374
8375 - Now pytest displays the total progress percentage while running tests. The
8376 previous output style can be set by configuring the ``console_output_style``
8377 setting to ``classic``. (:issue:`2657`)
8378
8379 - Match ``warns`` signature to ``raises`` by adding ``match`` keyword. (:issue:`2708`)
8380
8381 - pytest now captures and displays output from the standard ``logging`` module.
8382 The user can control the logging level to be captured by specifying options
8383 in ``pytest.ini``, the command line and also during individual tests using
8384 markers. Also, a ``caplog`` fixture is available that enables users to test
8385 the captured log during specific tests (similar to ``capsys`` for example).
8386 For more information, please see the :doc:`logging docs <how-to/logging>`. This feature was
8387 introduced by merging the popular :pypi:`pytest-catchlog` plugin, thanks to :user:`thisch`.
8388 Be advised that during the merging the
8389 backward compatibility interface with the defunct ``pytest-capturelog`` has
8390 been dropped. (:issue:`2794`)
8391
8392 - Add ``allow_module_level`` kwarg to ``pytest.skip()``, enabling to skip the
8393 whole module. (:issue:`2808`)
8394
8395 - Allow setting ``file_or_dir``, ``-c``, and ``-o`` in PYTEST_ADDOPTS. (:issue:`2824`)
8396
8397 - Return stdout/stderr capture results as a ``namedtuple``, so ``out`` and
8398 ``err`` can be accessed by attribute. (:issue:`2879`)
8399
8400 - Add ``capfdbinary``, a version of ``capfd`` which returns bytes from
8401 ``readouterr()``. (:issue:`2923`)
8402
8403 - Add ``capsysbinary`` a version of ``capsys`` which returns bytes from
8404 ``readouterr()``. (:issue:`2934`)
8405
8406 - Implement feature to skip ``setup.py`` files when run with
8407 ``--doctest-modules``. (:issue:`502`)
8408
8409
8410 Bug Fixes
8411 ---------
8412
8413 - Resume output capturing after ``capsys/capfd.disabled()`` context manager.
8414 (:issue:`1993`)
8415
8416 - ``pytest_fixture_setup`` and ``pytest_fixture_post_finalizer`` hooks are now
8417 called for all ``conftest.py`` files. (:issue:`2124`)
8418
8419 - If an exception happens while loading a plugin, pytest no longer hides the
8420 original traceback. In Python 2 it will show the original traceback with a new
8421 message that explains in which plugin. In Python 3 it will show 2 canonized
8422 exceptions, the original exception while loading the plugin in addition to an
8423 exception that pytest throws about loading a plugin. (:issue:`2491`)
8424
8425 - ``capsys`` and ``capfd`` can now be used by other fixtures. (:issue:`2709`)
8426
8427 - Internal ``pytester`` plugin properly encodes ``bytes`` arguments to
8428 ``utf-8``. (:issue:`2738`)
8429
8430 - ``testdir`` now uses use the same method used by ``tmpdir`` to create its
8431 temporary directory. This changes the final structure of the ``testdir``
8432 directory slightly, but should not affect usage in normal scenarios and
8433 avoids a number of potential problems. (:issue:`2751`)
8434
8435 - pytest no longer complains about warnings with unicode messages being
8436 non-ascii compatible even for ascii-compatible messages. As a result of this,
8437 warnings with unicode messages are converted first to an ascii representation
8438 for safety. (:issue:`2809`)
8439
8440 - Change return value of pytest command when ``--maxfail`` is reached from
8441 ``2`` (interrupted) to ``1`` (failed). (:issue:`2845`)
8442
8443 - Fix issue in assertion rewriting which could lead it to rewrite modules which
8444 should not be rewritten. (:issue:`2939`)
8445
8446 - Handle marks without description in ``pytest.ini``. (:issue:`2942`)
8447
8448
8449 Trivial/Internal Changes
8450 ------------------------
8451
8452 - pytest now depends on :pypi:`attrs` for internal
8453 structures to ease code maintainability. (:issue:`2641`)
8454
8455 - Refactored internal Python 2/3 compatibility code to use ``six``. (:issue:`2642`)
8456
8457 - Stop vendoring ``pluggy`` - we're missing out on its latest changes for not
8458 much benefit (:issue:`2719`)
8459
8460 - Internal refactor: simplify ascii string escaping by using the
8461 backslashreplace error handler in newer Python 3 versions. (:issue:`2734`)
8462
8463 - Remove unnecessary mark evaluator in unittest plugin (:issue:`2767`)
8464
8465 - Calls to ``Metafunc.addcall`` now emit a deprecation warning. This function
8466 is scheduled to be removed in ``pytest-4.0``. (:issue:`2876`)
8467
8468 - Internal move of the parameterset extraction to a more maintainable place.
8469 (:issue:`2877`)
8470
8471 - Internal refactoring to simplify scope node lookup. (:issue:`2910`)
8472
8473 - Configure ``pytest`` to prevent pip from installing pytest in unsupported
8474 Python versions. (:issue:`2922`)
8475
8476
8477 pytest 3.2.5 (2017-11-15)
8478 =========================
8479
8480 Bug Fixes
8481 ---------
8482
8483 - Remove ``py<1.5`` restriction from ``pytest`` as this can cause version
8484 conflicts in some installations. (:issue:`2926`)
8485
8486
8487 pytest 3.2.4 (2017-11-13)
8488 =========================
8489
8490 Bug Fixes
8491 ---------
8492
8493 - Fix the bug where running with ``--pyargs`` will result in items with
8494 empty ``parent.nodeid`` if run from a different root directory. (:issue:`2775`)
8495
8496 - Fix issue with ``@pytest.parametrize`` if argnames was specified as keyword arguments.
8497 (:issue:`2819`)
8498
8499 - Strip whitespace from marker names when reading them from INI config. (:issue:`2856`)
8500
8501 - Show full context of doctest source in the pytest output, if the line number of
8502 failed example in the docstring is < 9. (:issue:`2882`)
8503
8504 - Match fixture paths against actual path segments in order to avoid matching folders which share a prefix.
8505 (:issue:`2836`)
8506
8507 Improved Documentation
8508 ----------------------
8509
8510 - Introduce a dedicated section about conftest.py. (:issue:`1505`)
8511
8512 - Explicitly mention ``xpass`` in the documentation of ``xfail``. (:issue:`1997`)
8513
8514 - Append example for pytest.param in the example/parametrize document. (:issue:`2658`)
8515
8516 - Clarify language of proposal for fixtures parameters (:issue:`2893`)
8517
8518 - List python 3.6 in the documented supported versions in the getting started
8519 document. (:issue:`2903`)
8520
8521 - Clarify the documentation of available fixture scopes. (:issue:`538`)
8522
8523 - Add documentation about the ``python -m pytest`` invocation adding the
8524 current directory to sys.path. (:issue:`911`)
8525
8526
8527 pytest 3.2.3 (2017-10-03)
8528 =========================
8529
8530 Bug Fixes
8531 ---------
8532
8533 - Fix crash in tab completion when no prefix is given. (:issue:`2748`)
8534
8535 - The equality checking function (``__eq__``) of ``MarkDecorator`` returns
8536 ``False`` if one object is not an instance of ``MarkDecorator``. (:issue:`2758`)
8537
8538 - When running ``pytest --fixtures-per-test``: don't crash if an item has no
8539 _fixtureinfo attribute (e.g. doctests) (:issue:`2788`)
8540
8541
8542 Improved Documentation
8543 ----------------------
8544
8545 - In help text of ``-k`` option, add example of using ``not`` to not select
8546 certain tests whose names match the provided expression. (:issue:`1442`)
8547
8548 - Add note in ``parametrize.rst`` about calling ``metafunc.parametrize``
8549 multiple times. (:issue:`1548`)
8550
8551
8552 Trivial/Internal Changes
8553 ------------------------
8554
8555 - Set ``xfail_strict=True`` in pytest's own test suite to catch expected
8556 failures as soon as they start to pass. (:issue:`2722`)
8557
8558 - Fix typo in example of passing a callable to markers (in example/markers.rst)
8559 (:issue:`2765`)
8560
8561
8562 pytest 3.2.2 (2017-09-06)
8563 =========================
8564
8565 Bug Fixes
8566 ---------
8567
8568 - Calling the deprecated ``request.getfuncargvalue()`` now shows the source of
8569 the call. (:issue:`2681`)
8570
8571 - Allow tests declared as ``@staticmethod`` to use fixtures. (:issue:`2699`)
8572
8573 - Fixed edge-case during collection: attributes which raised ``pytest.fail``
8574 when accessed would abort the entire collection. (:issue:`2707`)
8575
8576 - Fix ``ReprFuncArgs`` with mixed unicode and UTF-8 args. (:issue:`2731`)
8577
8578
8579 Improved Documentation
8580 ----------------------
8581
8582 - In examples on working with custom markers, add examples demonstrating the
8583 usage of ``pytest.mark.MARKER_NAME.with_args`` in comparison with
8584 ``pytest.mark.MARKER_NAME.__call__`` (:issue:`2604`)
8585
8586 - In one of the simple examples, use ``pytest_collection_modifyitems()`` to skip
8587 tests based on a command-line option, allowing its sharing while preventing a
8588 user error when accessing ``pytest.config`` before the argument parsing.
8589 (:issue:`2653`)
8590
8591
8592 Trivial/Internal Changes
8593 ------------------------
8594
8595 - Fixed minor error in 'Good Practices/Manual Integration' code snippet.
8596 (:issue:`2691`)
8597
8598 - Fixed typo in goodpractices.rst. (:issue:`2721`)
8599
8600 - Improve user guidance regarding ``--resultlog`` deprecation. (:issue:`2739`)
8601
8602
8603 pytest 3.2.1 (2017-08-08)
8604 =========================
8605
8606 Bug Fixes
8607 ---------
8608
8609 - Fixed small terminal glitch when collecting a single test item. (:issue:`2579`)
8610
8611 - Correctly consider ``/`` as the file separator to automatically mark plugin
8612 files for rewrite on Windows. (:issue:`2591`)
8613
8614 - Properly escape test names when setting ``PYTEST_CURRENT_TEST`` environment
8615 variable. (:issue:`2644`)
8616
8617 - Fix error on Windows and Python 3.6+ when ``sys.stdout`` has been replaced
8618 with a stream-like object which does not implement the full ``io`` module
8619 buffer protocol. In particular this affects ``pytest-xdist`` users on the
8620 aforementioned platform. (:issue:`2666`)
8621
8622
8623 Improved Documentation
8624 ----------------------
8625
8626 - Explicitly document which pytest features work with ``unittest``. (:issue:`2626`)
8627
8628
8629 pytest 3.2.0 (2017-07-30)
8630 =========================
8631
8632 Deprecations and Removals
8633 -------------------------
8634
8635 - ``pytest.approx`` no longer supports ``>``, ``>=``, ``<`` and ``<=``
8636 operators to avoid surprising/inconsistent behavior. See the :func:`~pytest.approx` docs for more
8637 information. (:issue:`2003`)
8638
8639 - All old-style specific behavior in current classes in the pytest's API is
8640 considered deprecated at this point and will be removed in a future release.
8641 This affects Python 2 users only and in rare situations. (:issue:`2147`)
8642
8643 - A deprecation warning is now raised when using marks for parameters
8644 in ``pytest.mark.parametrize``. Use ``pytest.param`` to apply marks to
8645 parameters instead. (:issue:`2427`)
8646
8647
8648 Features
8649 --------
8650
8651 - Add support for numpy arrays (and dicts) to approx. (:issue:`1994`)
8652
8653 - Now test function objects have a ``pytestmark`` attribute containing a list
8654 of marks applied directly to the test function, as opposed to marks inherited
8655 from parent classes or modules. (:issue:`2516`)
8656
8657 - Collection ignores local virtualenvs by default; ``--collect-in-virtualenv``
8658 overrides this behavior. (:issue:`2518`)
8659
8660 - Allow class methods decorated as ``@staticmethod`` to be candidates for
8661 collection as a test function. (Only for Python 2.7 and above. Python 2.6
8662 will still ignore static methods.) (:issue:`2528`)
8663
8664 - Introduce ``mark.with_args`` in order to allow passing functions/classes as
8665 sole argument to marks. (:issue:`2540`)
8666
8667 - New ``cache_dir`` ini option: sets the directory where the contents of the
8668 cache plugin are stored. Directory may be relative or absolute path: if relative path, then
8669 directory is created relative to ``rootdir``, otherwise it is used as is.
8670 Additionally path may contain environment variables which are expanded during
8671 runtime. (:issue:`2543`)
8672
8673 - Introduce the ``PYTEST_CURRENT_TEST`` environment variable that is set with
8674 the ``nodeid`` and stage (``setup``, ``call`` and ``teardown``) of the test
8675 being currently executed. See the :ref:`documentation <pytest current test env>`
8676 for more info. (:issue:`2583`)
8677
8678 - Introduced ``@pytest.mark.filterwarnings`` mark which allows overwriting the
8679 warnings filter on a per test, class or module level. See the :ref:`docs <filterwarnings>`
8680 for more information. (:issue:`2598`)
8681
8682 - ``--last-failed`` now remembers forever when a test has failed and only
8683 forgets it if it passes again. This makes it easy to fix a test suite by
8684 selectively running files and fixing tests incrementally. (:issue:`2621`)
8685
8686 - New ``pytest_report_collectionfinish`` hook which allows plugins to add
8687 messages to the terminal reporting after collection has been finished
8688 successfully. (:issue:`2622`)
8689
8690 - Added support for :pep:`415`\'s
8691 ``Exception.__suppress_context__``. Now if a ``raise exception from None`` is
8692 caught by pytest, pytest will no longer chain the context in the test report.
8693 The behavior now matches Python's traceback behavior. (:issue:`2631`)
8694
8695 - Exceptions raised by ``pytest.fail``, ``pytest.skip`` and ``pytest.xfail``
8696 now subclass BaseException, making them harder to be caught unintentionally
8697 by normal code. (:issue:`580`)
8698
8699
8700 Bug Fixes
8701 ---------
8702
8703 - Set ``stdin`` to a closed ``PIPE`` in ``pytester.py.Testdir.popen()`` for
8704 avoid unwanted interactive ``pdb`` (:issue:`2023`)
8705
8706 - Add missing ``encoding`` attribute to ``sys.std*`` streams when using
8707 ``capsys`` capture mode. (:issue:`2375`)
8708
8709 - Fix terminal color changing to black on Windows if ``colorama`` is imported
8710 in a ``conftest.py`` file. (:issue:`2510`)
8711
8712 - Fix line number when reporting summary of skipped tests. (:issue:`2548`)
8713
8714 - capture: ensure that EncodedFile.name is a string. (:issue:`2555`)
8715
8716 - The options ``--fixtures`` and ``--fixtures-per-test`` will now keep
8717 indentation within docstrings. (:issue:`2574`)
8718
8719 - doctests line numbers are now reported correctly, fixing `pytest-sugar#122
8720 <https://github.com/Frozenball/pytest-sugar/issues/122>`_. (:issue:`2610`)
8721
8722 - Fix non-determinism in order of fixture collection. Adds new dependency
8723 (ordereddict) for Python 2.6. (:issue:`920`)
8724
8725
8726 Improved Documentation
8727 ----------------------
8728
8729 - Clarify ``pytest_configure`` hook call order. (:issue:`2539`)
8730
8731 - Extend documentation for testing plugin code with the ``pytester`` plugin.
8732 (:issue:`971`)
8733
8734
8735 Trivial/Internal Changes
8736 ------------------------
8737
8738 - Update help message for ``--strict`` to make it clear it only deals with
8739 unregistered markers, not warnings. (:issue:`2444`)
8740
8741 - Internal code move: move code for pytest.approx/pytest.raises to own files in
8742 order to cut down the size of python.py (:issue:`2489`)
8743
8744 - Renamed the utility function ``_pytest.compat._escape_strings`` to
8745 ``_ascii_escaped`` to better communicate the function's purpose. (:issue:`2533`)
8746
8747 - Improve error message for CollectError with skip/skipif. (:issue:`2546`)
8748
8749 - Emit warning about ``yield`` tests being deprecated only once per generator.
8750 (:issue:`2562`)
8751
8752 - Ensure final collected line doesn't include artifacts of previous write.
8753 (:issue:`2571`)
8754
8755 - Fixed all flake8 errors and warnings. (:issue:`2581`)
8756
8757 - Added ``fix-lint`` tox environment to run automatic pep8 fixes on the code.
8758 (:issue:`2582`)
8759
8760 - Turn warnings into errors in pytest's own test suite in order to catch
8761 regressions due to deprecations more promptly. (:issue:`2588`)
8762
8763 - Show multiple issue links in CHANGELOG entries. (:issue:`2620`)
8764
8765
8766 pytest 3.1.3 (2017-07-03)
8767 =========================
8768
8769 Bug Fixes
8770 ---------
8771
8772 - Fix decode error in Python 2 for doctests in docstrings. (:issue:`2434`)
8773
8774 - Exceptions raised during teardown by finalizers are now suppressed until all
8775 finalizers are called, with the initial exception reraised. (:issue:`2440`)
8776
8777 - Fix incorrect "collected items" report when specifying tests on the command-
8778 line. (:issue:`2464`)
8779
8780 - ``deprecated_call`` in context-manager form now captures deprecation warnings
8781 even if the same warning has already been raised. Also, ``deprecated_call``
8782 will always produce the same error message (previously it would produce
8783 different messages in context-manager vs. function-call mode). (:issue:`2469`)
8784
8785 - Fix issue where paths collected by pytest could have triple leading ``/``
8786 characters. (:issue:`2475`)
8787
8788 - Fix internal error when trying to detect the start of a recursive traceback.
8789 (:issue:`2486`)
8790
8791
8792 Improved Documentation
8793 ----------------------
8794
8795 - Explicitly state for which hooks the calls stop after the first non-None
8796 result. (:issue:`2493`)
8797
8798
8799 Trivial/Internal Changes
8800 ------------------------
8801
8802 - Create invoke tasks for updating the vendored packages. (:issue:`2474`)
8803
8804 - Update copyright dates in LICENSE, README.rst and in the documentation.
8805 (:issue:`2499`)
8806
8807
8808 pytest 3.1.2 (2017-06-08)
8809 =========================
8810
8811 Bug Fixes
8812 ---------
8813
8814 - Required options added via ``pytest_addoption`` will no longer prevent using
8815 --help without passing them. (#1999)
8816
8817 - Respect ``python_files`` in assertion rewriting. (#2121)
8818
8819 - Fix recursion error detection when frames in the traceback contain objects
8820 that can't be compared (like ``numpy`` arrays). (#2459)
8821
8822 - ``UnicodeWarning`` is issued from the internal pytest warnings plugin only
8823 when the message contains non-ascii unicode (Python 2 only). (#2463)
8824
8825 - Added a workaround for Python 3.6 ``WindowsConsoleIO`` breaking due to Pytests's
8826 ``FDCapture``. Other code using console handles might still be affected by the
8827 very same issue and might require further workarounds/fixes, i.e. ``colorama``.
8828 (#2467)
8829
8830
8831 Improved Documentation
8832 ----------------------
8833
8834 - Fix internal API links to ``pluggy`` objects. (#2331)
8835
8836 - Make it clear that ``pytest.xfail`` stops test execution at the calling point
8837 and improve overall flow of the ``skipping`` docs. (#810)
8838
8839
8840 pytest 3.1.1 (2017-05-30)
8841 =========================
8842
8843 Bug Fixes
8844 ---------
8845
8846 - pytest warning capture no longer overrides existing warning filters. The
8847 previous behaviour would override all filters and caused regressions in test
8848 suites which configure warning filters to match their needs. Note that as a
8849 side-effect of this is that ``DeprecationWarning`` and
8850 ``PendingDeprecationWarning`` are no longer shown by default. (#2430)
8851
8852 - Fix issue with non-ascii contents in doctest text files. (#2434)
8853
8854 - Fix encoding errors for unicode warnings in Python 2. (#2436)
8855
8856 - ``pytest.deprecated_call`` now captures ``PendingDeprecationWarning`` in
8857 context manager form. (#2441)
8858
8859
8860 Improved Documentation
8861 ----------------------
8862
8863 - Addition of towncrier for changelog management. (#2390)
8864
8865
8866 3.1.0 (2017-05-22)
8867 ==================
8868
8869
8870 New Features
8871 ------------
8872
8873 * The ``pytest-warnings`` plugin has been integrated into the core and now ``pytest`` automatically
8874 captures and displays warnings at the end of the test session.
8875
8876 .. warning::
8877
8878 This feature may disrupt test suites which apply and treat warnings themselves, and can be
8879 disabled in your ``pytest.ini``:
8880
8881 .. code-block:: ini
8882
8883 [pytest]
8884 addopts = -p no:warnings
8885
8886 See the :doc:`warnings documentation page <how-to/capture-warnings>` for more
8887 information.
8888
8889 Thanks :user:`nicoddemus` for the PR.
8890
8891 * Added ``junit_suite_name`` ini option to specify root ``<testsuite>`` name for JUnit XML reports (:issue:`533`).
8892
8893 * Added an ini option ``doctest_encoding`` to specify which encoding to use for doctest files.
8894 Thanks :user:`wheerd` for the PR (:pr:`2101`).
8895
8896 * ``pytest.warns`` now checks for subclass relationship rather than
8897 class equality. Thanks :user:`lesteve` for the PR (:pr:`2166`)
8898
8899 * ``pytest.raises`` now asserts that the error message matches a text or regex
8900 with the ``match`` keyword argument. Thanks :user:`Kriechi` for the PR.
8901
8902 * ``pytest.param`` can be used to declare test parameter sets with marks and test ids.
8903 Thanks :user:`RonnyPfannschmidt` for the PR.
8904
8905
8906 Changes
8907 -------
8908
8909 * remove all internal uses of pytest_namespace hooks,
8910 this is to prepare the removal of preloadconfig in pytest 4.0
8911 Thanks to :user:`RonnyPfannschmidt` for the PR.
8912
8913 * pytest now warns when a callable ids raises in a parametrized test. Thanks :user:`fogo` for the PR.
8914
8915 * It is now possible to skip test classes from being collected by setting a
8916 ``__test__`` attribute to ``False`` in the class body (:issue:`2007`). Thanks
8917 to :user:`syre` for the report and :user:`lwm` for the PR.
8918
8919 * Change junitxml.py to produce reports that comply with Junitxml schema.
8920 If the same test fails with failure in call and then errors in teardown
8921 we split testcase element into two, one containing the error and the other
8922 the failure. (:issue:`2228`) Thanks to :user:`kkoukiou` for the PR.
8923
8924 * Testcase reports with a ``url`` attribute will now properly write this to junitxml.
8925 Thanks :user:`fushi` for the PR (:pr:`1874`).
8926
8927 * Remove common items from dict comparison output when verbosity=1. Also update
8928 the truncation message to make it clearer that pytest truncates all
8929 assertion messages if verbosity < 2 (:issue:`1512`).
8930 Thanks :user:`mattduck` for the PR
8931
8932 * ``--pdbcls`` no longer implies ``--pdb``. This makes it possible to use
8933 ``addopts=--pdbcls=module.SomeClass`` on ``pytest.ini``. Thanks :user:`davidszotten` for
8934 the PR (:pr:`1952`).
8935
8936 * fix :issue:`2013`: turn RecordedWarning into ``namedtuple``,
8937 to give it a comprehensible repr while preventing unwarranted modification.
8938
8939 * fix :issue:`2208`: ensure an iteration limit for ``_pytest.compat.get_real_func``.
8940 Thanks :user:`RonnyPfannschmidt` for the report and PR.
8941
8942 * Hooks are now verified after collection is complete, rather than right after loading installed plugins. This
8943 makes it easy to write hooks for plugins which will be loaded during collection, for example using the
8944 ``pytest_plugins`` special variable (:issue:`1821`).
8945 Thanks :user:`nicoddemus` for the PR.
8946
8947 * Modify ``pytest_make_parametrize_id()`` hook to accept ``argname`` as an
8948 additional parameter.
8949 Thanks :user:`unsignedint` for the PR.
8950
8951 * Add ``venv`` to the default ``norecursedirs`` setting.
8952 Thanks :user:`The-Compiler` for the PR.
8953
8954 * ``PluginManager.import_plugin`` now accepts unicode plugin names in Python 2.
8955 Thanks :user:`reutsharabani` for the PR.
8956
8957 * fix :issue:`2308`: When using both ``--lf`` and ``--ff``, only the last failed tests are run.
8958 Thanks :user:`ojii` for the PR.
8959
8960 * Replace minor/patch level version numbers in the documentation with placeholders.
8961 This significantly reduces change-noise as different contributors regenerate
8962 the documentation on different platforms.
8963 Thanks :user:`RonnyPfannschmidt` for the PR.
8964
8965 * fix :issue:`2391`: consider pytest_plugins on all plugin modules
8966 Thanks :user:`RonnyPfannschmidt` for the PR.
8967
8968
8969 Bug Fixes
8970 ---------
8971
8972 * Fix ``AttributeError`` on ``sys.stdout.buffer`` / ``sys.stderr.buffer``
8973 while using ``capsys`` fixture in python 3. (:issue:`1407`).
8974 Thanks to :user:`asottile`.
8975
8976 * Change capture.py's ``DontReadFromInput`` class to throw ``io.UnsupportedOperation`` errors rather
8977 than ValueErrors in the ``fileno`` method (:issue:`2276`).
8978 Thanks :user:`metasyn` and :user:`vlad-dragos` for the PR.
8979
8980 * Fix exception formatting while importing modules when the exception message
8981 contains non-ascii characters (:issue:`2336`).
8982 Thanks :user:`fabioz` for the report and :user:`nicoddemus` for the PR.
8983
8984 * Added documentation related to issue (:issue:`1937`)
8985 Thanks :user:`skylarjhdownes` for the PR.
8986
8987 * Allow collecting files with any file extension as Python modules (:issue:`2369`).
8988 Thanks :user:`Kodiologist` for the PR.
8989
8990 * Show the correct error message when collect "parametrize" func with wrong args (:issue:`2383`).
8991 Thanks :user:`The-Compiler` for the report and :user:`robin0371` for the PR.
8992
8993
8994 3.0.7 (2017-03-14)
8995 ==================
8996
8997
8998 * Fix issue in assertion rewriting breaking due to modules silently discarding
8999 other modules when importing fails
9000 Notably, importing the ``anydbm`` module is fixed. (:issue:`2248`).
9001 Thanks :user:`pfhayes` for the PR.
9002
9003 * junitxml: Fix problematic case where system-out tag occurred twice per testcase
9004 element in the XML report. Thanks :user:`kkoukiou` for the PR.
9005
9006 * Fix regression, pytest now skips unittest correctly if run with ``--pdb``
9007 (:issue:`2137`). Thanks to :user:`gst` for the report and :user:`mbyt` for the PR.
9008
9009 * Ignore exceptions raised from descriptors (e.g. properties) during Python test collection (:issue:`2234`).
9010 Thanks to :user:`bluetech`.
9011
9012 * ``--override-ini`` now correctly overrides some fundamental options like ``python_files`` (:issue:`2238`).
9013 Thanks :user:`sirex` for the report and :user:`nicoddemus` for the PR.
9014
9015 * Replace ``raise StopIteration`` usages in the code by simple ``returns`` to finish generators, in accordance to :pep:`479` (:issue:`2160`).
9016 Thanks to :user:`nicoddemus` for the PR.
9017
9018 * Fix internal errors when an unprintable ``AssertionError`` is raised inside a test.
9019 Thanks :user:`omerhadari` for the PR.
9020
9021 * Skipping plugin now also works with test items generated by custom collectors (:issue:`2231`).
9022 Thanks to :user:`vidartf`.
9023
9024 * Fix trailing whitespace in console output if no .ini file presented (:issue:`2281`). Thanks :user:`fbjorn` for the PR.
9025
9026 * Conditionless ``xfail`` markers no longer rely on the underlying test item
9027 being an instance of ``PyobjMixin``, and can therefore apply to tests not
9028 collected by the built-in python test collector. Thanks :user:`barneygale` for the
9029 PR.
9030
9031
9032 3.0.6 (2017-01-22)
9033 ==================
9034
9035 * pytest no longer generates ``PendingDeprecationWarning`` from its own operations, which was introduced by mistake in version ``3.0.5`` (:issue:`2118`).
9036 Thanks to :user:`nicoddemus` for the report and :user:`RonnyPfannschmidt` for the PR.
9037
9038
9039 * pytest no longer recognizes coroutine functions as yield tests (:issue:`2129`).
9040 Thanks to :user:`malinoff` for the PR.
9041
9042 * Plugins loaded by the ``PYTEST_PLUGINS`` environment variable are now automatically
9043 considered for assertion rewriting (:issue:`2185`).
9044 Thanks :user:`nicoddemus` for the PR.
9045
9046 * Improve error message when pytest.warns fails (:issue:`2150`). The type(s) of the
9047 expected warnings and the list of caught warnings is added to the
9048 error message. Thanks :user:`lesteve` for the PR.
9049
9050 * Fix ``pytester`` internal plugin to work correctly with latest versions of
9051 ``zope.interface`` (:issue:`1989`). Thanks :user:`nicoddemus` for the PR.
9052
9053 * Assert statements of the ``pytester`` plugin again benefit from assertion rewriting (:issue:`1920`).
9054 Thanks :user:`RonnyPfannschmidt` for the report and :user:`nicoddemus` for the PR.
9055
9056 * Specifying tests with colons like ``test_foo.py::test_bar`` for tests in
9057 subdirectories with ini configuration files now uses the correct ini file
9058 (:issue:`2148`). Thanks :user:`pelme`.
9059
9060 * Fail ``testdir.runpytest().assert_outcomes()`` explicitly if the pytest
9061 terminal output it relies on is missing. Thanks to :user:`eli-b` for the PR.
9062
9063
9064 3.0.5 (2016-12-05)
9065 ==================
9066
9067 * Add warning when not passing ``option=value`` correctly to ``-o/--override-ini`` (:issue:`2105`).
9068 Also improved the help documentation. Thanks to :user:`mbukatov` for the report and
9069 :user:`lwm` for the PR.
9070
9071 * Now ``--confcutdir`` and ``--junit-xml`` are properly validated if they are directories
9072 and filenames, respectively (:issue:`2089` and :issue:`2078`). Thanks to :user:`lwm` for the PR.
9073
9074 * Add hint to error message hinting possible missing ``__init__.py`` (:issue:`478`). Thanks :user:`DuncanBetts`.
9075
9076 * More accurately describe when fixture finalization occurs in documentation (:issue:`687`). Thanks :user:`DuncanBetts`.
9077
9078 * Provide ``:ref:`` targets for ``recwarn.rst`` so we can use intersphinx referencing.
9079 Thanks to :user:`dupuy` for the report and :user:`lwm` for the PR.
9080
9081 * In Python 2, use a simple ``+-`` ASCII string in the string representation of ``pytest.approx`` (for example ``"4 +- 4.0e-06"``)
9082 because it is brittle to handle that in different contexts and representations internally in pytest
9083 which can result in bugs such as :issue:`2111`. In Python 3, the representation still uses ``±`` (for example ``4 ± 4.0e-06``).
9084 Thanks :user:`kerrick-lyft` for the report and :user:`nicoddemus` for the PR.
9085
9086 * Using ``item.Function``, ``item.Module``, etc., is now issuing deprecation warnings, prefer
9087 ``pytest.Function``, ``pytest.Module``, etc., instead (:issue:`2034`).
9088 Thanks :user:`nmundar` for the PR.
9089
9090 * Fix error message using ``approx`` with complex numbers (:issue:`2082`).
9091 Thanks :user:`adler-j` for the report and :user:`nicoddemus` for the PR.
9092
9093 * Fixed false-positives warnings from assertion rewrite hook for modules imported more than
9094 once by the ``pytest_plugins`` mechanism.
9095 Thanks :user:`nicoddemus` for the PR.
9096
9097 * Remove an internal cache which could cause hooks from ``conftest.py`` files in
9098 sub-directories to be called in other directories incorrectly (:issue:`2016`).
9099 Thanks :user:`d-b-w` for the report and :user:`nicoddemus` for the PR.
9100
9101 * Remove internal code meant to support earlier Python 3 versions that produced the side effect
9102 of leaving ``None`` in ``sys.modules`` when expressions were evaluated by pytest (for example passing a condition
9103 as a string to ``pytest.mark.skipif``)(:issue:`2103`).
9104 Thanks :user:`jaraco` for the report and :user:`nicoddemus` for the PR.
9105
9106 * Cope gracefully with a .pyc file with no matching .py file (:issue:`2038`). Thanks
9107 :user:`nedbat`.
9108
9109
9110 3.0.4 (2016-11-09)
9111 ==================
9112
9113 * Import errors when collecting test modules now display the full traceback (:issue:`1976`).
9114 Thanks :user:`cwitty` for the report and :user:`nicoddemus` for the PR.
9115
9116 * Fix confusing command-line help message for custom options with two or more ``metavar`` properties (:issue:`2004`).
9117 Thanks :user:`okulynyak` and :user:`davehunt` for the report and :user:`nicoddemus` for the PR.
9118
9119 * When loading plugins, import errors which contain non-ascii messages are now properly handled in Python 2 (:issue:`1998`).
9120 Thanks :user:`nicoddemus` for the PR.
9121
9122 * Fixed cyclic reference when ``pytest.raises`` is used in context-manager form (:issue:`1965`). Also as a
9123 result of this fix, ``sys.exc_info()`` is left empty in both context-manager and function call usages.
9124 Previously, ``sys.exc_info`` would contain the exception caught by the context manager,
9125 even when the expected exception occurred.
9126 Thanks :user:`MSeifert04` for the report and the PR.
9127
9128 * Fixed false-positives warnings from assertion rewrite hook for modules that were rewritten but
9129 were later marked explicitly by ``pytest.register_assert_rewrite``
9130 or implicitly as a plugin (:issue:`2005`).
9131 Thanks :user:`RonnyPfannschmidt` for the report and :user:`nicoddemus` for the PR.
9132
9133 * Report teardown output on test failure (:issue:`442`).
9134 Thanks :user:`matclab` for the PR.
9135
9136 * Fix teardown error message in generated xUnit XML.
9137 Thanks :user:`gdyuldin` for the PR.
9138
9139 * Properly handle exceptions in ``multiprocessing`` tasks (:issue:`1984`).
9140 Thanks :user:`adborden` for the report and :user:`nicoddemus` for the PR.
9141
9142 * Clean up unittest TestCase objects after tests are complete (:issue:`1649`).
9143 Thanks :user:`d-b-w` for the report and PR.
9144
9145
9146 3.0.3 (2016-09-28)
9147 ==================
9148
9149 * The ``ids`` argument to ``parametrize`` again accepts ``unicode`` strings
9150 in Python 2 (:issue:`1905`).
9151 Thanks :user:`philpep` for the report and :user:`nicoddemus` for the PR.
9152
9153 * Assertions are now being rewritten for plugins in development mode
9154 (``pip install -e``) (:issue:`1934`).
9155 Thanks :user:`nicoddemus` for the PR.
9156
9157 * Fix pkg_resources import error in Jython projects (:issue:`1853`).
9158 Thanks :user:`raquelalegre` for the PR.
9159
9160 * Got rid of ``AttributeError: 'Module' object has no attribute '_obj'`` exception
9161 in Python 3 (:issue:`1944`).
9162 Thanks :user:`axil` for the PR.
9163
9164 * Explain a bad scope value passed to ``@fixture`` declarations or
9165 a ``MetaFunc.parametrize()`` call.
9166
9167 * This version includes ``pluggy-0.4.0``, which correctly handles
9168 ``VersionConflict`` errors in plugins (:issue:`704`).
9169 Thanks :user:`nicoddemus` for the PR.
9170
9171
9172 3.0.2 (2016-09-01)
9173 ==================
9174
9175 * Improve error message when passing non-string ids to ``pytest.mark.parametrize`` (:issue:`1857`).
9176 Thanks :user:`okken` for the report and :user:`nicoddemus` for the PR.
9177
9178 * Add ``buffer`` attribute to stdin stub class ``pytest.capture.DontReadFromInput``
9179 Thanks :user:`joguSD` for the PR.
9180
9181 * Fix ``UnicodeEncodeError`` when string comparison with unicode has failed. (:issue:`1864`)
9182 Thanks :user:`AiOO` for the PR.
9183
9184 * ``pytest_plugins`` is now handled correctly if defined as a string (as opposed as
9185 a sequence of strings) when modules are considered for assertion rewriting.
9186 Due to this bug, much more modules were being rewritten than necessary
9187 if a test suite uses ``pytest_plugins`` to load internal plugins (:issue:`1888`).
9188 Thanks :user:`jaraco` for the report and :user:`nicoddemus` for the PR (:pr:`1891`).
9189
9190 * Do not call tearDown and cleanups when running tests from
9191 ``unittest.TestCase`` subclasses with ``--pdb``
9192 enabled. This allows proper post mortem debugging for all applications
9193 which have significant logic in their tearDown machinery (:issue:`1890`). Thanks
9194 :user:`mbyt` for the PR.
9195
9196 * Fix use of deprecated ``getfuncargvalue`` method in the internal doctest plugin.
9197 Thanks :user:`ViviCoder` for the report (:issue:`1898`).
9198
9199
9200 3.0.1 (2016-08-23)
9201 ==================
9202
9203 * Fix regression when ``importorskip`` is used at module level (:issue:`1822`).
9204 Thanks :user:`jaraco` and :user:`The-Compiler` for the report and :user:`nicoddemus` for the PR.
9205
9206 * Fix parametrization scope when session fixtures are used in conjunction
9207 with normal parameters in the same call (:issue:`1832`).
9208 Thanks :user:`The-Compiler` for the report, :user:`Kingdread` and :user:`nicoddemus` for the PR.
9209
9210 * Fix internal error when parametrizing tests or fixtures using an empty ``ids`` argument (:issue:`1849`).
9211 Thanks :user:`OPpuolitaival` for the report and :user:`nicoddemus` for the PR.
9212
9213 * Fix loader error when running ``pytest`` embedded in a zipfile.
9214 Thanks :user:`mbachry` for the PR.
9215
9216
9217 .. _release-3.0.0:
9218
9219 3.0.0 (2016-08-18)
9220 ==================
9221
9222 **Incompatible changes**
9223
9224
9225 A number of incompatible changes were made in this release, with the intent of removing features deprecated for a long
9226 time or change existing behaviors in order to make them less surprising/more useful.
9227
9228 * Reinterpretation mode has now been removed. Only plain and rewrite
9229 mode are available, consequently the ``--assert=reinterp`` option is
9230 no longer available. This also means files imported from plugins or
9231 ``conftest.py`` will not benefit from improved assertions by
9232 default, you should use ``pytest.register_assert_rewrite()`` to
9233 explicitly turn on assertion rewriting for those files. Thanks
9234 :user:`flub` for the PR.
9235
9236 * The following deprecated commandline options were removed:
9237
9238 * ``--genscript``: no longer supported;
9239 * ``--no-assert``: use ``--assert=plain`` instead;
9240 * ``--nomagic``: use ``--assert=plain`` instead;
9241 * ``--report``: use ``-r`` instead;
9242
9243 Thanks to :user:`RedBeardCode` for the PR (:pr:`1664`).
9244
9245 * ImportErrors in plugins now are a fatal error instead of issuing a
9246 pytest warning (:issue:`1479`). Thanks to :user:`The-Compiler` for the PR.
9247
9248 * Removed support code for Python 3 versions < 3.3 (:pr:`1627`).
9249
9250 * Removed all ``py.test-X*`` entry points. The versioned, suffixed entry points
9251 were never documented and a leftover from a pre-virtualenv era. These entry
9252 points also created broken entry points in wheels, so removing them also
9253 removes a source of confusion for users (:issue:`1632`).
9254 Thanks :user:`obestwalter` for the PR.
9255
9256 * ``pytest.skip()`` now raises an error when used to decorate a test function,
9257 as opposed to its original intent (to imperatively skip a test inside a test function). Previously
9258 this usage would cause the entire module to be skipped (:issue:`607`).
9259 Thanks :user:`omarkohl` for the complete PR (:pr:`1519`).
9260
9261 * Exit tests if a collection error occurs. A poll indicated most users will hit CTRL-C
9262 anyway as soon as they see collection errors, so pytest might as well make that the default behavior (:issue:`1421`).
9263 A ``--continue-on-collection-errors`` option has been added to restore the previous behaviour.
9264 Thanks :user:`olegpidsadnyi` and :user:`omarkohl` for the complete PR (:pr:`1628`).
9265
9266 * Renamed the pytest ``pdb`` module (plugin) into ``debugging`` to avoid clashes with the builtin ``pdb`` module.
9267
9268 * Raise a helpful failure message when requesting a parametrized fixture at runtime,
9269 e.g. with ``request.getfixturevalue``. Previously these parameters were simply
9270 never defined, so a fixture decorated like ``@pytest.fixture(params=[0, 1, 2])``
9271 only ran once (:pr:`460`).
9272 Thanks to :user:`nikratio` for the bug report, :user:`RedBeardCode` and :user:`tomviner` for the PR.
9273
9274 * ``_pytest.monkeypatch.monkeypatch`` class has been renamed to ``_pytest.monkeypatch.MonkeyPatch``
9275 so it doesn't conflict with the ``monkeypatch`` fixture.
9276
9277 * ``--exitfirst / -x`` can now be overridden by a following ``--maxfail=N``
9278 and is just a synonym for ``--maxfail=1``.
9279
9280
9281 **New Features**
9282
9283 * Support nose-style ``__test__`` attribute on methods of classes,
9284 including unittest-style Classes. If set to ``False``, the test will not be
9285 collected.
9286
9287 * New ``doctest_namespace`` fixture for injecting names into the
9288 namespace in which doctests run.
9289 Thanks :user:`milliams` for the complete PR (:pr:`1428`).
9290
9291 * New ``--doctest-report`` option available to change the output format of diffs
9292 when running (failing) doctests (implements :issue:`1749`).
9293 Thanks :user:`hartym` for the PR.
9294
9295 * New ``name`` argument to ``pytest.fixture`` decorator which allows a custom name
9296 for a fixture (to solve the funcarg-shadowing-fixture problem).
9297 Thanks :user:`novas0x2a` for the complete PR (:pr:`1444`).
9298
9299 * New ``approx()`` function for easily comparing floating-point numbers in
9300 tests.
9301 Thanks :user:`kalekundert` for the complete PR (:pr:`1441`).
9302
9303 * Ability to add global properties in the final xunit output file by accessing
9304 the internal ``junitxml`` plugin (experimental).
9305 Thanks :user:`tareqalayan` for the complete PR :pr:`1454`).
9306
9307 * New ``ExceptionInfo.match()`` method to match a regular expression on the
9308 string representation of an exception (:issue:`372`).
9309 Thanks :user:`omarkohl` for the complete PR (:pr:`1502`).
9310
9311 * ``__tracebackhide__`` can now also be set to a callable which then can decide
9312 whether to filter the traceback based on the ``ExceptionInfo`` object passed
9313 to it. Thanks :user:`The-Compiler` for the complete PR (:pr:`1526`).
9314
9315 * New ``pytest_make_parametrize_id(config, val)`` hook which can be used by plugins to provide
9316 friendly strings for custom types.
9317 Thanks :user:`palaviv` for the PR.
9318
9319 * ``capsys`` and ``capfd`` now have a ``disabled()`` context-manager method, which
9320 can be used to temporarily disable capture within a test.
9321 Thanks :user:`nicoddemus` for the PR.
9322
9323 * New cli flag ``--fixtures-per-test``: shows which fixtures are being used
9324 for each selected test item. Features doc strings of fixtures by default.
9325 Can also show where fixtures are defined if combined with ``-v``.
9326 Thanks :user:`hackebrot` for the PR.
9327
9328 * Introduce ``pytest`` command as recommended entry point. Note that ``py.test``
9329 still works and is not scheduled for removal. Closes proposal
9330 :issue:`1629`. Thanks :user:`obestwalter` and :user:`davehunt` for the complete PR
9331 (:pr:`1633`).
9332
9333 * New cli flags:
9334
9335 + ``--setup-plan``: performs normal collection and reports
9336 the potential setup and teardown and does not execute any fixtures and tests;
9337 + ``--setup-only``: performs normal collection, executes setup and teardown of
9338 fixtures and reports them;
9339 + ``--setup-show``: performs normal test execution and additionally shows
9340 setup and teardown of fixtures;
9341 + ``--keep-duplicates``: py.test now ignores duplicated paths given in the command
9342 line. To retain the previous behavior where the same test could be run multiple
9343 times by specifying it in the command-line multiple times, pass the ``--keep-duplicates``
9344 argument (:issue:`1609`);
9345
9346 Thanks :user:`d6e`, :user:`kvas-it`, :user:`sallner`, :user:`ioggstream` and :user:`omarkohl` for the PRs.
9347
9348 * New CLI flag ``--override-ini``/``-o``: overrides values from the ini file.
9349 For example: ``"-o xfail_strict=True"``'.
9350 Thanks :user:`blueyed` and :user:`fengxx` for the PR.
9351
9352 * New hooks:
9353
9354 + ``pytest_fixture_setup(fixturedef, request)``: executes fixture setup;
9355 + ``pytest_fixture_post_finalizer(fixturedef)``: called after the fixture's
9356 finalizer and has access to the fixture's result cache.
9357
9358 Thanks :user:`d6e`, :user:`sallner`.
9359
9360 * Issue warnings for asserts whose test is a tuple literal. Such asserts will
9361 never fail because tuples are always truthy and are usually a mistake
9362 (see :issue:`1562`). Thanks :user:`kvas-it`, for the PR.
9363
9364 * Allow passing a custom debugger class (e.g. ``--pdbcls=IPython.core.debugger:Pdb``).
9365 Thanks to :user:`anntzer` for the PR.
9366
9367
9368 **Changes**
9369
9370 * Plugins now benefit from assertion rewriting. Thanks
9371 :user:`sober7`, :user:`nicoddemus` and :user:`flub` for the PR.
9372
9373 * Change ``report.outcome`` for ``xpassed`` tests to ``"passed"`` in non-strict
9374 mode and ``"failed"`` in strict mode. Thanks to :user:`hackebrot` for the PR
9375 (:pr:`1795`) and :user:`gprasad84` for report (:issue:`1546`).
9376
9377 * Tests marked with ``xfail(strict=False)`` (the default) now appear in
9378 JUnitXML reports as passing tests instead of skipped.
9379 Thanks to :user:`hackebrot` for the PR (:pr:`1795`).
9380
9381 * Highlight path of the file location in the error report to make it easier to copy/paste.
9382 Thanks :user:`suzaku` for the PR (:pr:`1778`).
9383
9384 * Fixtures marked with ``@pytest.fixture`` can now use ``yield`` statements exactly like
9385 those marked with the ``@pytest.yield_fixture`` decorator. This change renders
9386 ``@pytest.yield_fixture`` deprecated and makes ``@pytest.fixture`` with ``yield`` statements
9387 the preferred way to write teardown code (:pr:`1461`).
9388 Thanks :user:`csaftoiu` for bringing this to attention and :user:`nicoddemus` for the PR.
9389
9390 * Explicitly passed parametrize ids do not get escaped to ascii (:issue:`1351`).
9391 Thanks :user:`ceridwen` for the PR.
9392
9393 * Fixtures are now sorted in the error message displayed when an unknown
9394 fixture is declared in a test function.
9395 Thanks :user:`nicoddemus` for the PR.
9396
9397 * ``pytest_terminal_summary`` hook now receives the ``exitstatus``
9398 of the test session as argument. Thanks :user:`blueyed` for the PR (:pr:`1809`).
9399
9400 * Parametrize ids can accept ``None`` as specific test id, in which case the
9401 automatically generated id for that argument will be used.
9402 Thanks :user:`palaviv` for the complete PR (:pr:`1468`).
9403
9404 * The parameter to xunit-style setup/teardown methods (``setup_method``,
9405 ``setup_module``, etc.) is now optional and may be omitted.
9406 Thanks :user:`okken` for bringing this to attention and :user:`nicoddemus` for the PR.
9407
9408 * Improved automatic id generation selection in case of duplicate ids in
9409 parametrize.
9410 Thanks :user:`palaviv` for the complete PR (:pr:`1474`).
9411
9412 * Now pytest warnings summary is shown up by default. Added a new flag
9413 ``--disable-pytest-warnings`` to explicitly disable the warnings summary (:issue:`1668`).
9414
9415 * Make ImportError during collection more explicit by reminding
9416 the user to check the name of the test module/package(s) (:issue:`1426`).
9417 Thanks :user:`omarkohl` for the complete PR (:pr:`1520`).
9418
9419 * Add ``build/`` and ``dist/`` to the default ``--norecursedirs`` list. Thanks
9420 :user:`mikofski` for the report and :user:`tomviner` for the PR (:issue:`1544`).
9421
9422 * ``pytest.raises`` in the context manager form accepts a custom
9423 ``message`` to raise when no exception occurred.
9424 Thanks :user:`palaviv` for the complete PR (:pr:`1616`).
9425
9426 * ``conftest.py`` files now benefit from assertion rewriting; previously it
9427 was only available for test modules. Thanks :user:`flub`, :user:`sober7` and
9428 :user:`nicoddemus` for the PR (:issue:`1619`).
9429
9430 * Text documents without any doctests no longer appear as "skipped".
9431 Thanks :user:`graingert` for reporting and providing a full PR (:pr:`1580`).
9432
9433 * Ensure that a module within a namespace package can be found when it
9434 is specified on the command line together with the ``--pyargs``
9435 option. Thanks to :user:`taschini` for the PR (:pr:`1597`).
9436
9437 * Always include full assertion explanation during assertion rewriting. The previous behaviour was hiding
9438 sub-expressions that happened to be ``False``, assuming this was redundant information.
9439 Thanks :user:`bagerard` for reporting (:issue:`1503`). Thanks to :user:`davehunt` and
9440 :user:`tomviner` for the PR.
9441
9442 * ``OptionGroup.addoption()`` now checks if option names were already
9443 added before, to make it easier to track down issues like :issue:`1618`.
9444 Before, you only got exceptions later from ``argparse`` library,
9445 giving no clue about the actual reason for double-added options.
9446
9447 * ``yield``-based tests are considered deprecated and will be removed in pytest-4.0.
9448 Thanks :user:`nicoddemus` for the PR.
9449
9450 * ``[pytest]`` sections in ``setup.cfg`` files should now be named ``[tool:pytest]``
9451 to avoid conflicts with other distutils commands (see :pr:`567`). ``[pytest]`` sections in
9452 ``pytest.ini`` or ``tox.ini`` files are supported and unchanged.
9453 Thanks :user:`nicoddemus` for the PR.
9454
9455 * Using ``pytest_funcarg__`` prefix to declare fixtures is considered deprecated and will be
9456 removed in pytest-4.0 (:pr:`1684`).
9457 Thanks :user:`nicoddemus` for the PR.
9458
9459 * Passing a command-line string to ``pytest.main()`` is considered deprecated and scheduled
9460 for removal in pytest-4.0. It is recommended to pass a list of arguments instead (:pr:`1723`).
9461
9462 * Rename ``getfuncargvalue`` to ``getfixturevalue``. ``getfuncargvalue`` is
9463 still present but is now considered deprecated. Thanks to :user:`RedBeardCode` and :user:`tomviner`
9464 for the PR (:pr:`1626`).
9465
9466 * ``optparse`` type usage now triggers DeprecationWarnings (:issue:`1740`).
9467
9468
9469 * ``optparse`` backward compatibility supports float/complex types (:issue:`457`).
9470
9471 * Refined logic for determining the ``rootdir``, considering only valid
9472 paths which fixes a number of issues: :issue:`1594`, :issue:`1435` and :issue:`1471`.
9473 Updated the documentation according to current behavior. Thanks to
9474 :user:`blueyed`, :user:`davehunt` and :user:`matthiasha` for the PR.
9475
9476 * Always include full assertion explanation. The previous behaviour was hiding
9477 sub-expressions that happened to be False, assuming this was redundant information.
9478 Thanks :user:`bagerard` for reporting (:issue:`1503`). Thanks to :user:`davehunt` and
9479 :user:`tomviner` for PR.
9480
9481 * Better message in case of not using parametrized variable (see :issue:`1539`).
9482 Thanks to :user:`tramwaj29` for the PR.
9483
9484 * Updated docstrings with a more uniform style.
9485
9486 * Add stderr write for ``pytest.exit(msg)`` during startup. Previously the message was never shown.
9487 Thanks :user:`BeyondEvil` for reporting :issue:`1210`. Thanks to @jgsonesen and
9488 :user:`tomviner` for the PR.
9489
9490 * No longer display the incorrect test deselection reason (:issue:`1372`).
9491 Thanks :user:`ronnypfannschmidt` for the PR.
9492
9493 * The ``--resultlog`` command line option has been deprecated: it is little used
9494 and there are more modern and better alternatives (see :issue:`830`).
9495 Thanks :user:`nicoddemus` for the PR.
9496
9497 * Improve error message with fixture lookup errors: add an 'E' to the first
9498 line and '>' to the rest. Fixes :issue:`717`. Thanks :user:`blueyed` for reporting and
9499 a PR, :user:`eolo999` for the initial PR and :user:`tomviner` for his guidance during
9500 EuroPython2016 sprint.
9501
9502
9503 **Bug Fixes**
9504
9505 * Parametrize now correctly handles duplicated test ids.
9506
9507 * Fix internal error issue when the ``method`` argument is missing for
9508 ``teardown_method()`` (:issue:`1605`).
9509
9510 * Fix exception visualization in case the current working directory (CWD) gets
9511 deleted during testing (:issue:`1235`). Thanks :user:`bukzor` for reporting. PR by
9512 :user:`marscher`.
9513
9514 * Improve test output for logical expression with brackets (:issue:`925`).
9515 Thanks :user:`DRMacIver` for reporting and :user:`RedBeardCode` for the PR.
9516
9517 * Create correct diff for strings ending with newlines (:issue:`1553`).
9518 Thanks :user:`Vogtinator` for reporting and :user:`RedBeardCode` and
9519 :user:`tomviner` for the PR.
9520
9521 * ``ConftestImportFailure`` now shows the traceback making it easier to
9522 identify bugs in ``conftest.py`` files (:pr:`1516`). Thanks :user:`txomon` for
9523 the PR.
9524
9525 * Text documents without any doctests no longer appear as "skipped".
9526 Thanks :user:`graingert` for reporting and providing a full PR (:pr:`1580`).
9527
9528 * Fixed collection of classes with custom ``__new__`` method.
9529 Fixes :issue:`1579`. Thanks to :user:`Stranger6667` for the PR.
9530
9531 * Fixed scope overriding inside metafunc.parametrize (:issue:`634`).
9532 Thanks to :user:`Stranger6667` for the PR.
9533
9534 * Fixed the total tests tally in junit xml output (:pr:`1798`).
9535 Thanks to :user:`cboelsen` for the PR.
9536
9537 * Fixed off-by-one error with lines from ``request.node.warn``.
9538 Thanks to :user:`blueyed` for the PR.
9539
9540
9541 2.9.2 (2016-05-31)
9542 ==================
9543
9544 **Bug Fixes**
9545
9546 * fix :issue:`510`: skip tests where one parameterize dimension was empty
9547 thanks Alex Stapleton for the Report and :user:`RonnyPfannschmidt` for the PR
9548
9549 * Fix Xfail does not work with condition keyword argument.
9550 Thanks :user:`astraw38` for reporting the issue (:issue:`1496`) and :user:`tomviner`
9551 for PR the (:pr:`1524`).
9552
9553 * Fix win32 path issue when putting custom config file with absolute path
9554 in ``pytest.main("-c your_absolute_path")``.
9555
9556 * Fix maximum recursion depth detection when raised error class is not aware
9557 of unicode/encoded bytes.
9558 Thanks :user:`prusse-martin` for the PR (:pr:`1506`).
9559
9560 * Fix ``pytest.mark.skip`` mark when used in strict mode.
9561 Thanks :user:`pquentin` for the PR and :user:`RonnyPfannschmidt` for
9562 showing how to fix the bug.
9563
9564 * Minor improvements and fixes to the documentation.
9565 Thanks :user:`omarkohl` for the PR.
9566
9567 * Fix ``--fixtures`` to show all fixture definitions as opposed to just
9568 one per fixture name.
9569 Thanks to :user:`hackebrot` for the PR.
9570
9571
9572 2.9.1 (2016-03-17)
9573 ==================
9574
9575 **Bug Fixes**
9576
9577 * Improve error message when a plugin fails to load.
9578 Thanks :user:`nicoddemus` for the PR.
9579
9580 * Fix (:issue:`1178`):
9581 ``pytest.fail`` with non-ascii characters raises an internal pytest error.
9582 Thanks :user:`nicoddemus` for the PR.
9583
9584 * Fix (:issue:`469`): junit parses report.nodeid incorrectly, when params IDs
9585 contain ``::``. Thanks :user:`tomviner` for the PR (:pr:`1431`).
9586
9587 * Fix (:issue:`578`): SyntaxErrors
9588 containing non-ascii lines at the point of failure generated an internal
9589 py.test error.
9590 Thanks :user:`asottile` for the report and :user:`nicoddemus` for the PR.
9591
9592 * Fix (:issue:`1437`): When passing in a bytestring regex pattern to parameterize
9593 attempt to decode it as utf-8 ignoring errors.
9594
9595 * Fix (:issue:`649`): parametrized test nodes cannot be specified to run on the command line.
9596
9597 * Fix (:issue:`138`): better reporting for python 3.3+ chained exceptions
9598
9599
9600 2.9.0 (2016-02-29)
9601 ==================
9602
9603 **New Features**
9604
9605 * New ``pytest.mark.skip`` mark, which unconditionally skips marked tests.
9606 Thanks :user:`MichaelAquilina` for the complete PR (:pr:`1040`).
9607
9608 * ``--doctest-glob`` may now be passed multiple times in the command-line.
9609 Thanks :user:`jab` and :user:`nicoddemus` for the PR.
9610
9611 * New ``-rp`` and ``-rP`` reporting options give the summary and full output
9612 of passing tests, respectively. Thanks to :user:`codewarrior0` for the PR.
9613
9614 * ``pytest.mark.xfail`` now has a ``strict`` option, which makes ``XPASS``
9615 tests to fail the test suite (defaulting to ``False``). There's also a
9616 ``xfail_strict`` ini option that can be used to configure it project-wise.
9617 Thanks :user:`rabbbit` for the request and :user:`nicoddemus` for the PR (:pr:`1355`).
9618
9619 * ``Parser.addini`` now supports options of type ``bool``.
9620 Thanks :user:`nicoddemus` for the PR.
9621
9622 * New ``ALLOW_BYTES`` doctest option. This strips ``b`` prefixes from byte strings
9623 in doctest output (similar to ``ALLOW_UNICODE``).
9624 Thanks :user:`jaraco` for the request and :user:`nicoddemus` for the PR (:pr:`1287`).
9625
9626 * Give a hint on ``KeyboardInterrupt`` to use the ``--fulltrace`` option to show the errors.
9627 Fixes :issue:`1366`.
9628 Thanks to :user:`hpk42` for the report and :user:`RonnyPfannschmidt` for the PR.
9629
9630 * Catch ``IndexError`` exceptions when getting exception source location.
9631 Fixes a pytest internal error for dynamically generated code (fixtures and tests)
9632 where source lines are fake by intention.
9633
9634 **Changes**
9635
9636 * **Important**: `py.code <https://pylib.readthedocs.io/en/stable/code.html>`_ has been
9637 merged into the ``pytest`` repository as ``pytest._code``. This decision
9638 was made because ``py.code`` had very few uses outside ``pytest`` and the
9639 fact that it was in a different repository made it difficult to fix bugs on
9640 its code in a timely manner. The team hopes with this to be able to better
9641 refactor out and improve that code.
9642 This change shouldn't affect users, but it is useful to let users aware
9643 if they encounter any strange behavior.
9644
9645 Keep in mind that the code for ``pytest._code`` is **private** and
9646 **experimental**, so you definitely should not import it explicitly!
9647
9648 Please note that the original ``py.code`` is still available in
9649 `pylib <https://pylib.readthedocs.io>`_.
9650
9651 * ``pytest_enter_pdb`` now optionally receives the pytest config object.
9652 Thanks :user:`nicoddemus` for the PR.
9653
9654 * Removed code and documentation for Python 2.5 or lower versions,
9655 including removal of the obsolete ``_pytest.assertion.oldinterpret`` module.
9656 Thanks :user:`nicoddemus` for the PR (:pr:`1226`).
9657
9658 * Comparisons now always show up in full when ``CI`` or ``BUILD_NUMBER`` is
9659 found in the environment, even when ``-vv`` isn't used.
9660 Thanks :user:`The-Compiler` for the PR.
9661
9662 * ``--lf`` and ``--ff`` now support long names: ``--last-failed`` and
9663 ``--failed-first`` respectively.
9664 Thanks :user:`MichaelAquilina` for the PR.
9665
9666 * Added expected exceptions to ``pytest.raises`` fail message.
9667
9668 * Collection only displays progress ("collecting X items") when in a terminal.
9669 This avoids cluttering the output when using ``--color=yes`` to obtain
9670 colors in CI integrations systems (:issue:`1397`).
9671
9672 **Bug Fixes**
9673
9674 * The ``-s`` and ``-c`` options should now work under ``xdist``;
9675 ``Config.fromdictargs`` now represents its input much more faithfully.
9676 Thanks to :user:`bukzor` for the complete PR (:issue:`680`).
9677
9678 * Fix (:issue:`1290`): support Python 3.5's ``@`` operator in assertion rewriting.
9679 Thanks :user:`Shinkenjoe` for report with test case and :user:`tomviner` for the PR.
9680
9681 * Fix formatting utf-8 explanation messages (:issue:`1379`).
9682 Thanks :user:`biern` for the PR.
9683
9684 * Fix :ref:`traceback style docs <how-to-modifying-python-tb-printing>` to describe all of the available options
9685 (auto/long/short/line/native/no), with ``auto`` being the default since v2.6.
9686 Thanks :user:`hackebrot` for the PR.
9687
9688 * Fix (:issue:`1422`): junit record_xml_property doesn't allow multiple records
9689 with same name.
9690
9691
9692 2.8.7 (2016-01-24)
9693 ==================
9694
9695 - fix #1338: use predictable object resolution for monkeypatch
9696
9697 2.8.6 (2016-01-21)
9698 ==================
9699
9700 - fix #1259: allow for double nodeids in junitxml,
9701 this was a regression failing plugins combinations
9702 like pytest-pep8 + pytest-flakes
9703
9704 - Workaround for exception that occurs in pyreadline when using
9705 ``--pdb`` with standard I/O capture enabled.
9706 Thanks Erik M. Bray for the PR.
9707
9708 - fix #900: Better error message in case the target of a ``monkeypatch`` call
9709 raises an ``ImportError``.
9710
9711 - fix #1292: monkeypatch calls (setattr, setenv, etc.) are now O(1).
9712 Thanks David R. MacIver for the report and Bruno Oliveira for the PR.
9713
9714 - fix #1223: captured stdout and stderr are now properly displayed before
9715 entering pdb when ``--pdb`` is used instead of being thrown away.
9716 Thanks Cal Leeming for the PR.
9717
9718 - fix #1305: pytest warnings emitted during ``pytest_terminal_summary`` are now
9719 properly displayed.
9720 Thanks Ionel Maries Cristian for the report and Bruno Oliveira for the PR.
9721
9722 - fix #628: fixed internal UnicodeDecodeError when doctests contain unicode.
9723 Thanks Jason R. Coombs for the report and Bruno Oliveira for the PR.
9724
9725 - fix #1334: Add captured stdout to jUnit XML report on setup error.
9726 Thanks Georgy Dyuldin for the PR.
9727
9728
9729 2.8.5 (2015-12-11)
9730 ==================
9731
9732 - fix #1243: fixed issue where class attributes injected during collection could break pytest.
9733 PR by Alexei Kozlenok, thanks Ronny Pfannschmidt and Bruno Oliveira for the review and help.
9734
9735 - fix #1074: precompute junitxml chunks instead of storing the whole tree in objects
9736 Thanks Bruno Oliveira for the report and Ronny Pfannschmidt for the PR
9737
9738 - fix #1238: fix ``pytest.deprecated_call()`` receiving multiple arguments
9739 (Regression introduced in 2.8.4). Thanks Alex Gaynor for the report and
9740 Bruno Oliveira for the PR.
9741
9742
9743 2.8.4 (2015-12-06)
9744 ==================
9745
9746 - fix #1190: ``deprecated_call()`` now works when the deprecated
9747 function has been already called by another test in the same
9748 module. Thanks Mikhail Chernykh for the report and Bruno Oliveira for the
9749 PR.
9750
9751 - fix #1198: ``--pastebin`` option now works on Python 3. Thanks
9752 Mehdy Khoshnoody for the PR.
9753
9754 - fix #1219: ``--pastebin`` now works correctly when captured output contains
9755 non-ascii characters. Thanks Bruno Oliveira for the PR.
9756
9757 - fix #1204: another error when collecting with a nasty __getattr__().
9758 Thanks Freya Bruhin for the PR.
9759
9760 - fix the summary printed when no tests did run.
9761 Thanks Freya Bruhin for the PR.
9762 - fix #1185 - ensure MANIFEST.in exactly matches what should go to a sdist
9763
9764 - a number of documentation modernizations wrt good practices.
9765 Thanks Bruno Oliveira for the PR.
9766
9767 2.8.3 (2015-11-18)
9768 ==================
9769
9770 - fix #1169: add __name__ attribute to testcases in TestCaseFunction to
9771 support the @unittest.skip decorator on functions and methods.
9772 Thanks Lee Kamentsky for the PR.
9773
9774 - fix #1035: collecting tests if test module level obj has __getattr__().
9775 Thanks Suor for the report and Bruno Oliveira / Tom Viner for the PR.
9776
9777 - fix #331: don't collect tests if their failure cannot be reported correctly
9778 e.g. they are a callable instance of a class.
9779
9780 - fix #1133: fixed internal error when filtering tracebacks where one entry
9781 belongs to a file which is no longer available.
9782 Thanks Bruno Oliveira for the PR.
9783
9784 - enhancement made to highlight in red the name of the failing tests so
9785 they stand out in the output.
9786 Thanks Gabriel Reis for the PR.
9787
9788 - add more talks to the documentation
9789 - extend documentation on the --ignore cli option
9790 - use pytest-runner for setuptools integration
9791 - minor fixes for interaction with OS X El Capitan
9792 system integrity protection (thanks Florian)
9793
9794
9795 2.8.2 (2015-10-07)
9796 ==================
9797
9798 - fix #1085: proper handling of encoding errors when passing encoded byte
9799 strings to pytest.parametrize in Python 2.
9800 Thanks Themanwithoutaplan for the report and Bruno Oliveira for the PR.
9801
9802 - fix #1087: handling SystemError when passing empty byte strings to
9803 pytest.parametrize in Python 3.
9804 Thanks Paul Kehrer for the report and Bruno Oliveira for the PR.
9805
9806 - fix #995: fixed internal error when filtering tracebacks where one entry
9807 was generated by an exec() statement.
9808 Thanks Daniel Hahler, Ashley C Straw, Philippe Gauthier and Pavel Savchenko
9809 for contributing and Bruno Oliveira for the PR.
9810
9811 - fix #1100 and #1057: errors when using autouse fixtures and doctest modules.
9812 Thanks Sergey B Kirpichev and Vital Kudzelka for contributing and Bruno
9813 Oliveira for the PR.
9814
9815 2.8.1 (2015-09-29)
9816 ==================
9817
9818 - fix #1034: Add missing nodeid on pytest_logwarning call in
9819 addhook. Thanks Simon Gomizelj for the PR.
9820
9821 - 'deprecated_call' is now only satisfied with a DeprecationWarning or
9822 PendingDeprecationWarning. Before 2.8.0, it accepted any warning, and 2.8.0
9823 made it accept only DeprecationWarning (but not PendingDeprecationWarning).
9824 Thanks Alex Gaynor for the issue and Eric Hunsberger for the PR.
9825
9826 - fix issue #1073: avoid calling __getattr__ on potential plugin objects.
9827 This fixes an incompatibility with pytest-django. Thanks Andreas Pelme,
9828 Bruno Oliveira and Ronny Pfannschmidt for contributing and Holger Krekel
9829 for the fix.
9830
9831 - Fix issue #704: handle versionconflict during plugin loading more
9832 gracefully. Thanks Bruno Oliveira for the PR.
9833
9834 - Fix issue #1064: ""--junitxml" regression when used with the
9835 "pytest-xdist" plugin, with test reports being assigned to the wrong tests.
9836 Thanks Daniel Grunwald for the report and Bruno Oliveira for the PR.
9837
9838 - (experimental) adapt more SEMVER style versioning and change meaning of
9839 master branch in git repo: "master" branch now keeps the bug fixes, changes
9840 aimed for micro releases. "features" branch will only be released
9841 with minor or major pytest releases.
9842
9843 - Fix issue #766 by removing documentation references to distutils.
9844 Thanks Russel Winder.
9845
9846 - Fix issue #1030: now byte-strings are escaped to produce item node ids
9847 to make them always serializable.
9848 Thanks Andy Freeland for the report and Bruno Oliveira for the PR.
9849
9850 - Python 2: if unicode parametrized values are convertible to ascii, their
9851 ascii representation is used for the node id.
9852
9853 - Fix issue #411: Add __eq__ method to assertion comparison example.
9854 Thanks Ben Webb.
9855 - Fix issue #653: deprecated_call can be used as context manager.
9856
9857 - fix issue 877: properly handle assertion explanations with non-ascii repr
9858 Thanks Mathieu Agopian for the report and Ronny Pfannschmidt for the PR.
9859
9860 - fix issue 1029: transform errors when writing cache values into pytest-warnings
9861
9862 2.8.0 (2015-09-18)
9863 ==================
9864
9865 - new ``--lf`` and ``-ff`` options to run only the last failing tests or
9866 "failing tests first" from the last run. This functionality is provided
9867 through porting the formerly external pytest-cache plugin into pytest core.
9868 BACKWARD INCOMPAT: if you used pytest-cache's functionality to persist
9869 data between test runs be aware that we don't serialize sets anymore.
9870 Thanks Ronny Pfannschmidt for most of the merging work.
9871
9872 - "-r" option now accepts "a" to include all possible reports, similar
9873 to passing "fEsxXw" explicitly (issue960).
9874 Thanks Abhijeet Kasurde for the PR.
9875
9876 - avoid python3.5 deprecation warnings by introducing version
9877 specific inspection helpers, thanks Michael Droettboom.
9878
9879 - fix issue562: @nose.tools.istest now fully respected.
9880
9881 - fix issue934: when string comparison fails and a diff is too large to display
9882 without passing -vv, still show a few lines of the diff.
9883 Thanks Freya Bruhin for the report and Bruno Oliveira for the PR.
9884
9885 - fix issue736: Fix a bug where fixture params would be discarded when combined
9886 with parametrization markers.
9887 Thanks to Markus Unterwaditzer for the PR.
9888
9889 - fix issue710: introduce ALLOW_UNICODE doctest option: when enabled, the
9890 ``u`` prefix is stripped from unicode strings in expected doctest output. This
9891 allows doctests which use unicode to run in Python 2 and 3 unchanged.
9892 Thanks Jason R. Coombs for the report and Bruno Oliveira for the PR.
9893
9894 - parametrize now also generates meaningful test IDs for enum, regex and class
9895 objects (as opposed to class instances).
9896 Thanks to Freya Bruhin for the PR.
9897
9898 - Add 'warns' to assert that warnings are thrown (like 'raises').
9899 Thanks to Eric Hunsberger for the PR.
9900
9901 - Fix issue683: Do not apply an already applied mark. Thanks ojake for the PR.
9902
9903 - Deal with capturing failures better so fewer exceptions get lost to
9904 /dev/null. Thanks David Szotten for the PR.
9905
9906 - fix issue730: deprecate and warn about the --genscript option.
9907 Thanks Ronny Pfannschmidt for the report and Christian Pommranz for the PR.
9908
9909 - fix issue751: multiple parametrize with ids bug if it parametrizes class with
9910 two or more test methods. Thanks Sergey Chipiga for reporting and Jan
9911 Bednarik for PR.
9912
9913 - fix issue82: avoid loading conftest files from setup.cfg/pytest.ini/tox.ini
9914 files and upwards by default (--confcutdir can still be set to override this).
9915 Thanks Bruno Oliveira for the PR.
9916
9917 - fix issue768: docstrings found in python modules were not setting up session
9918 fixtures. Thanks Jason R. Coombs for reporting and Bruno Oliveira for the PR.
9919
9920 - added ``tmpdir_factory``, a session-scoped fixture that can be used to create
9921 directories under the base temporary directory. Previously this object was
9922 installed as a ``_tmpdirhandler`` attribute of the ``config`` object, but now it
9923 is part of the official API and using ``config._tmpdirhandler`` is
9924 deprecated.
9925 Thanks Bruno Oliveira for the PR.
9926
9927 - fix issue808: pytest's internal assertion rewrite hook now implements the
9928 optional :pep:`302` get_data API so tests can access data files next to them.
9929 Thanks xmo-odoo for request and example and Bruno Oliveira for
9930 the PR.
9931
9932 - rootdir and inifile are now displayed during usage errors to help
9933 users diagnose problems such as unexpected ini files which add
9934 unknown options being picked up by pytest. Thanks to Pavel Savchenko for
9935 bringing the problem to attention in #821 and Bruno Oliveira for the PR.
9936
9937 - Summary bar now is colored yellow for warning
9938 situations such as: all tests either were skipped or xpass/xfailed,
9939 or no tests were run at all (this is a partial fix for issue500).
9940
9941 - fix issue812: pytest now exits with status code 5 in situations where no
9942 tests were run at all, such as the directory given in the command line does
9943 not contain any tests or as result of a command line option filters
9944 all out all tests (-k for example).
9945 Thanks Eric Siegerman (issue812) and Bruno Oliveira for the PR.
9946
9947 - Summary bar now is colored yellow for warning
9948 situations such as: all tests either were skipped or xpass/xfailed,
9949 or no tests were run at all (related to issue500).
9950 Thanks Eric Siegerman.
9951
9952 - New ``testpaths`` ini option: list of directories to search for tests
9953 when executing pytest from the root directory. This can be used
9954 to speed up test collection when a project has well specified directories
9955 for tests, being usually more practical than configuring norecursedirs for
9956 all directories that do not contain tests.
9957 Thanks to Adrian for idea (#694) and Bruno Oliveira for the PR.
9958
9959 - fix issue713: JUnit XML reports for doctest failures.
9960 Thanks Punyashloka Biswal.
9961
9962 - fix issue970: internal pytest warnings now appear as "pytest-warnings" in
9963 the terminal instead of "warnings", so it is clear for users that those
9964 warnings are from pytest and not from the builtin "warnings" module.
9965 Thanks Bruno Oliveira.
9966
9967 - Include setup and teardown in junitxml test durations.
9968 Thanks Janne Vanhala.
9969
9970 - fix issue735: assertion failures on debug versions of Python 3.4+
9971
9972 - new option ``--import-mode`` to allow to change test module importing
9973 behaviour to append to sys.path instead of prepending. This better allows
9974 to run test modules against installed versions of a package even if the
9975 package under test has the same import root. In this example::
9976
9977 testing/__init__.py
9978 testing/test_pkg_under_test.py
9979 pkg_under_test/
9980
9981 the tests will run against the installed version
9982 of pkg_under_test when ``--import-mode=append`` is used whereas
9983 by default they would always pick up the local version. Thanks Holger Krekel.
9984
9985 - pytester: add method ``TmpTestdir.delete_loaded_modules()``, and call it
9986 from ``inline_run()`` to allow temporary modules to be reloaded.
9987 Thanks Eduardo Schettino.
9988
9989 - internally refactor pluginmanager API and code so that there
9990 is a clear distinction between a pytest-agnostic rather simple
9991 pluginmanager and the PytestPluginManager which adds a lot of
9992 behaviour, among it handling of the local conftest files.
9993 In terms of documented methods this is a backward compatible
9994 change but it might still break 3rd party plugins which relied on
9995 details like especially the pluginmanager.add_shutdown() API.
9996 Thanks Holger Krekel.
9997
9998 - pluginmanagement: introduce ``pytest.hookimpl`` and
9999 ``pytest.hookspec`` decorators for setting impl/spec
10000 specific parameters. This substitutes the previous
10001 now deprecated use of ``pytest.mark`` which is meant to
10002 contain markers for test functions only.
10003
10004 - write/refine docs for "writing plugins" which now have their
10005 own page and are separate from the "using/installing plugins`` page.
10006
10007 - fix issue732: properly unregister plugins from any hook calling
10008 sites allowing to have temporary plugins during test execution.
10009
10010 - deprecate and warn about ``__multicall__`` argument in hook
10011 implementations. Use the ``hookwrapper`` mechanism instead already
10012 introduced with pytest-2.7.
10013
10014 - speed up pytest's own test suite considerably by using inprocess
10015 tests by default (testrun can be modified with --runpytest=subprocess
10016 to create subprocesses in many places instead). The main
10017 APIs to run pytest in a test is "runpytest()" or "runpytest_subprocess"
10018 and "runpytest_inprocess" if you need a particular way of running
10019 the test. In all cases you get back a RunResult but the inprocess
10020 one will also have a "reprec" attribute with the recorded events/reports.
10021
10022 - fix monkeypatch.setattr("x.y", raising=False) to actually not raise
10023 if "y" is not a preexisting attribute. Thanks Freya Bruhin.
10024
10025 - fix issue741: make running output from testdir.run copy/pasteable
10026 Thanks Bruno Oliveira.
10027
10028 - add a new ``--noconftest`` argument which ignores all ``conftest.py`` files.
10029
10030 - add ``file`` and ``line`` attributes to JUnit-XML output.
10031
10032 - fix issue890: changed extension of all documentation files from ``txt`` to
10033 ``rst``. Thanks to Abhijeet for the PR.
10034
10035 - fix issue714: add ability to apply indirect=True parameter on particular argnames.
10036 Thanks Elizaveta239.
10037
10038 - fix issue890: changed extension of all documentation files from ``txt`` to
10039 ``rst``. Thanks to Abhijeet for the PR.
10040
10041 - fix issue957: "# doctest: SKIP" option will now register doctests as SKIPPED
10042 rather than PASSED.
10043 Thanks Thomas Grainger for the report and Bruno Oliveira for the PR.
10044
10045 - issue951: add new record_xml_property fixture, that supports logging
10046 additional information on xml output. Thanks David Diaz for the PR.
10047
10048 - issue949: paths after normal options (for example ``-s``, ``-v``, etc) are now
10049 properly used to discover ``rootdir`` and ``ini`` files.
10050 Thanks Peter Lauri for the report and Bruno Oliveira for the PR.
10051
10052 2.7.3 (2015-09-15)
10053 ==================
10054
10055 - Allow 'dev', 'rc', or other non-integer version strings in ``importorskip``.
10056 Thanks to Eric Hunsberger for the PR.
10057
10058 - fix issue856: consider --color parameter in all outputs (for example
10059 --fixtures). Thanks Barney Gale for the report and Bruno Oliveira for the PR.
10060
10061 - fix issue855: passing str objects as ``plugins`` argument to pytest.main
10062 is now interpreted as a module name to be imported and registered as a
10063 plugin, instead of silently having no effect.
10064 Thanks xmo-odoo for the report and Bruno Oliveira for the PR.
10065
10066 - fix issue744: fix for ast.Call changes in Python 3.5+. Thanks
10067 Guido van Rossum, Matthias Bussonnier, Stefan Zimmermann and
10068 Thomas Kluyver.
10069
10070 - fix issue842: applying markers in classes no longer propagate this markers
10071 to superclasses which also have markers.
10072 Thanks xmo-odoo for the report and Bruno Oliveira for the PR.
10073
10074 - preserve warning functions after call to pytest.deprecated_call. Thanks
10075 Pieter Mulder for PR.
10076
10077 - fix issue854: autouse yield_fixtures defined as class members of
10078 unittest.TestCase subclasses now work as expected.
10079 Thanks xmo-odoo for the report and Bruno Oliveira for the PR.
10080
10081 - fix issue833: --fixtures now shows all fixtures of collected test files, instead of just the
10082 fixtures declared on the first one.
10083 Thanks Freya Bruhin for reporting and Bruno Oliveira for the PR.
10084
10085 - fix issue863: skipped tests now report the correct reason when a skip/xfail
10086 condition is met when using multiple markers.
10087 Thanks Raphael Pierzina for reporting and Bruno Oliveira for the PR.
10088
10089 - optimized tmpdir fixture initialization, which should make test sessions
10090 faster (specially when using pytest-xdist). The only visible effect
10091 is that now pytest uses a subdirectory in the $TEMP directory for all
10092 directories created by this fixture (defaults to $TEMP/pytest-$USER).
10093 Thanks Bruno Oliveira for the PR.
10094
10095 2.7.2 (2015-06-23)
10096 ==================
10097
10098 - fix issue767: pytest.raises value attribute does not contain the exception
10099 instance on Python 2.6. Thanks Eric Siegerman for providing the test
10100 case and Bruno Oliveira for PR.
10101
10102 - Automatically create directory for junitxml and results log.
10103 Thanks Aron Curzon.
10104
10105 - fix issue713: JUnit XML reports for doctest failures.
10106 Thanks Punyashloka Biswal.
10107
10108 - fix issue735: assertion failures on debug versions of Python 3.4+
10109 Thanks Benjamin Peterson.
10110
10111 - fix issue114: skipif marker reports to internal skipping plugin;
10112 Thanks Floris Bruynooghe for reporting and Bruno Oliveira for the PR.
10113
10114 - fix issue748: unittest.SkipTest reports to internal pytest unittest plugin.
10115 Thanks Thomas De Schampheleire for reporting and Bruno Oliveira for the PR.
10116
10117 - fix issue718: failed to create representation of sets containing unsortable
10118 elements in python 2. Thanks Edison Gustavo Muenz.
10119
10120 - fix issue756, fix issue752 (and similar issues): depend on py-1.4.29
10121 which has a refined algorithm for traceback generation.
10122
10123
10124 2.7.1 (2015-05-19)
10125 ==================
10126
10127 - fix issue731: do not get confused by the braces which may be present
10128 and unbalanced in an object's repr while collapsing False
10129 explanations. Thanks Carl Meyer for the report and test case.
10130
10131 - fix issue553: properly handling inspect.getsourcelines failures in
10132 FixtureLookupError which would lead to an internal error,
10133 obfuscating the original problem. Thanks talljosh for initial
10134 diagnose/patch and Bruno Oliveira for final patch.
10135
10136 - fix issue660: properly report scope-mismatch-access errors
10137 independently from ordering of fixture arguments. Also
10138 avoid the pytest internal traceback which does not provide
10139 information to the user. Thanks Holger Krekel.
10140
10141 - streamlined and documented release process. Also all versions
10142 (in setup.py and documentation generation) are now read
10143 from _pytest/__init__.py. Thanks Holger Krekel.
10144
10145 - fixed docs to remove the notion that yield-fixtures are experimental.
10146 They are here to stay :) Thanks Bruno Oliveira.
10147
10148 - Support building wheels by using environment markers for the
10149 requirements. Thanks Ionel Maries Cristian.
10150
10151 - fixed regression to 2.6.4 which surfaced e.g. in lost stdout capture printing
10152 when tests raised SystemExit. Thanks Holger Krekel.
10153
10154 - reintroduced _pytest fixture of the pytester plugin which is used
10155 at least by pytest-xdist.
10156
10157 2.7.0 (2015-03-26)
10158 ==================
10159
10160 - fix issue435: make reload() work when assert rewriting is active.
10161 Thanks Daniel Hahler.
10162
10163 - fix issue616: conftest.py files and their contained fixtures are now
10164 properly considered for visibility, independently from the exact
10165 current working directory and test arguments that are used.
10166 Many thanks to Eric Siegerman and his PR235 which contains
10167 systematic tests for conftest visibility and now passes.
10168 This change also introduces the concept of a ``rootdir`` which
10169 is printed as a new pytest header and documented in the pytest
10170 customize web page.
10171
10172 - change reporting of "diverted" tests, i.e. tests that are collected
10173 in one file but actually come from another (e.g. when tests in a test class
10174 come from a base class in a different file). We now show the nodeid
10175 and indicate via a postfix the other file.
10176
10177 - add ability to set command line options by environment variable PYTEST_ADDOPTS.
10178
10179 - added documentation on the new pytest-dev teams on bitbucket and
10180 github. See https://pytest.org/en/stable/contributing.html .
10181 Thanks to Anatoly for pushing and initial work on this.
10182
10183 - fix issue650: new option ``--doctest-ignore-import-errors`` which
10184 will turn import errors in doctests into skips. Thanks Charles Cloud
10185 for the complete PR.
10186
10187 - fix issue655: work around different ways that cause python2/3
10188 to leak sys.exc_info into fixtures/tests causing failures in 3rd party code
10189
10190 - fix issue615: assertion rewriting did not correctly escape % signs
10191 when formatting boolean operations, which tripped over mixing
10192 booleans with modulo operators. Thanks to Tom Viner for the report,
10193 triaging and fix.
10194
10195 - implement issue351: add ability to specify parametrize ids as a callable
10196 to generate custom test ids. Thanks Brianna Laugher for the idea and
10197 implementation.
10198
10199 - introduce and document new hookwrapper mechanism useful for plugins
10200 which want to wrap the execution of certain hooks for their purposes.
10201 This supersedes the undocumented ``__multicall__`` protocol which
10202 pytest itself and some external plugins use. Note that pytest-2.8
10203 is scheduled to drop supporting the old ``__multicall__``
10204 and only support the hookwrapper protocol.
10205
10206 - majorly speed up invocation of plugin hooks
10207
10208 - use hookwrapper mechanism in builtin pytest plugins.
10209
10210 - add a doctest ini option for doctest flags, thanks Holger Peters.
10211
10212 - add note to docs that if you want to mark a parameter and the
10213 parameter is a callable, you also need to pass in a reason to disambiguate
10214 it from the "decorator" case. Thanks Tom Viner.
10215
10216 - "python_classes" and "python_functions" options now support glob-patterns
10217 for test discovery, as discussed in issue600. Thanks Ldiary Translations.
10218
10219 - allow to override parametrized fixtures with non-parametrized ones and vice versa (bubenkoff).
10220
10221 - fix issue463: raise specific error for 'parameterize' misspelling (pfctdayelise).
10222
10223 - On failure, the ``sys.last_value``, ``sys.last_type`` and
10224 ``sys.last_traceback`` are set, so that a user can inspect the error
10225 via postmortem debugging (almarklein).
10226
10227 2.6.4 (2014-10-24)
10228 ==================
10229
10230 - Improve assertion failure reporting on iterables, by using ndiff and
10231 pprint.
10232
10233 - removed outdated japanese docs from source tree.
10234
10235 - docs for "pytest_addhooks" hook. Thanks Bruno Oliveira.
10236
10237 - updated plugin index docs. Thanks Bruno Oliveira.
10238
10239 - fix issue557: with "-k" we only allow the old style "-" for negation
10240 at the beginning of strings and even that is deprecated. Use "not" instead.
10241 This should allow to pick parametrized tests where "-" appeared in the parameter.
10242
10243 - fix issue604: Escape % character in the assertion message.
10244
10245 - fix issue620: add explanation in the --genscript target about what
10246 the binary blob means. Thanks Dinu Gherman.
10247
10248 - fix issue614: fixed pastebin support.
10249
10250
10251 - fix issue620: add explanation in the --genscript target about what
10252 the binary blob means. Thanks Dinu Gherman.
10253
10254 - fix issue614: fixed pastebin support.
10255
10256 2.6.3 (2014-09-24)
10257 ==================
10258
10259 - fix issue575: xunit-xml was reporting collection errors as failures
10260 instead of errors, thanks Oleg Sinyavskiy.
10261
10262 - fix issue582: fix setuptools example, thanks Laszlo Papp and Ronny
10263 Pfannschmidt.
10264
10265 - Fix infinite recursion bug when pickling capture.EncodedFile, thanks
10266 Uwe Schmitt.
10267
10268 - fix issue589: fix bad interaction with numpy and others when showing
10269 exceptions. Check for precise "maximum recursion depth exceed" exception
10270 instead of presuming any RuntimeError is that one (implemented in py
10271 dep). Thanks Charles Cloud for analysing the issue.
10272
10273 - fix conftest related fixture visibility issue: when running with a
10274 CWD outside of a test package pytest would get fixture discovery wrong.
10275 Thanks to Wolfgang Schnerring for figuring out a reproducible example.
10276
10277 - Introduce pytest_enter_pdb hook (needed e.g. by pytest_timeout to cancel the
10278 timeout when interactively entering pdb). Thanks Wolfgang Schnerring.
10279
10280 - check xfail/skip also with non-python function test items. Thanks
10281 Floris Bruynooghe.
10282
10283 2.6.2 (2014-09-05)
10284 ==================
10285
10286 - Added function pytest.freeze_includes(), which makes it easy to embed
10287 pytest into executables using tools like cx_freeze.
10288 See docs for examples and rationale. Thanks Bruno Oliveira.
10289
10290 - Improve assertion rewriting cache invalidation precision.
10291
10292 - fixed issue561: adapt autouse fixture example for python3.
10293
10294 - fixed issue453: assertion rewriting issue with __repr__ containing
10295 "\n{", "\n}" and "\n~".
10296
10297 - fix issue560: correctly display code if an "else:" or "finally:" is
10298 followed by statements on the same line.
10299
10300 - Fix example in monkeypatch documentation, thanks t-8ch.
10301
10302 - fix issue572: correct tmpdir doc example for python3.
10303
10304 - Do not mark as universal wheel because Python 2.6 is different from
10305 other builds due to the extra argparse dependency. Fixes issue566.
10306 Thanks sontek.
10307
10308 - Implement issue549: user-provided assertion messages now no longer
10309 replace the py.test introspection message but are shown in addition
10310 to them.
10311
10312 2.6.1 (2014-08-07)
10313 ==================
10314
10315 - No longer show line numbers in the --verbose output, the output is now
10316 purely the nodeid. The line number is still shown in failure reports.
10317 Thanks Floris Bruynooghe.
10318
10319 - fix issue437 where assertion rewriting could cause pytest-xdist worker nodes
10320 to collect different tests. Thanks Bruno Oliveira.
10321
10322 - fix issue555: add "errors" attribute to capture-streams to satisfy
10323 some distutils and possibly other code accessing sys.stdout.errors.
10324
10325 - fix issue547 capsys/capfd also work when output capturing ("-s") is disabled.
10326
10327 - address issue170: allow pytest.mark.xfail(...) to specify expected exceptions via
10328 an optional "raises=EXC" argument where EXC can be a single exception
10329 or a tuple of exception classes. Thanks David Mohr for the complete
10330 PR.
10331
10332 - fix integration of pytest with unittest.mock.patch decorator when
10333 it uses the "new" argument. Thanks Nicolas Delaby for test and PR.
10334
10335 - fix issue with detecting conftest files if the arguments contain
10336 "::" node id specifications (copy pasted from "-v" output)
10337
10338 - fix issue544 by only removing "@NUM" at the end of "::" separated parts
10339 and if the part has a ".py" extension
10340
10341 - don't use py.std import helper, rather import things directly.
10342 Thanks Bruno Oliveira.
10343
10344 2.6
10345 ===
10346
10347 - Cache exceptions from fixtures according to their scope (issue 467).
10348
10349 - fix issue537: Avoid importing old assertion reinterpretation code by default.
10350
10351 - fix issue364: shorten and enhance tracebacks representation by default.
10352 The new "--tb=auto" option (default) will only display long tracebacks
10353 for the first and last entry. You can get the old behaviour of printing
10354 all entries as long entries with "--tb=long". Also short entries by
10355 default are now printed very similarly to "--tb=native" ones.
10356
10357 - fix issue514: teach assertion reinterpretation about private class attributes
10358
10359 - change -v output to include full node IDs of tests. Users can copy
10360 a node ID from a test run, including line number, and use it as a
10361 positional argument in order to run only a single test.
10362
10363 - fix issue 475: fail early and comprehensible if calling
10364 pytest.raises with wrong exception type.
10365
10366 - fix issue516: tell in getting-started about current dependencies.
10367
10368 - cleanup setup.py a bit and specify supported versions. Thanks Jurko
10369 Gospodnetic for the PR.
10370
10371 - change XPASS colour to yellow rather than red when tests are run
10372 with -v.
10373
10374 - fix issue473: work around mock putting an unbound method into a class
10375 dict when double-patching.
10376
10377 - fix issue498: if a fixture finalizer fails, make sure that
10378 the fixture is still invalidated.
10379
10380 - fix issue453: the result of the pytest_assertrepr_compare hook now gets
10381 it's newlines escaped so that format_exception does not blow up.
10382
10383 - internal new warning system: pytest will now produce warnings when
10384 it detects oddities in your test collection or execution.
10385 Warnings are ultimately sent to a new pytest_logwarning hook which is
10386 currently only implemented by the terminal plugin which displays
10387 warnings in the summary line and shows more details when -rw (report on
10388 warnings) is specified.
10389
10390 - change skips into warnings for test classes with an __init__ and
10391 callables in test modules which look like a test but are not functions.
10392
10393 - fix issue436: improved finding of initial conftest files from command
10394 line arguments by using the result of parse_known_args rather than
10395 the previous flaky heuristics. Thanks Marc Abramowitz for tests
10396 and initial fixing approaches in this area.
10397
10398 - fix issue #479: properly handle nose/unittest(2) SkipTest exceptions
10399 during collection/loading of test modules. Thanks to Marc Schlaich
10400 for the complete PR.
10401
10402 - fix issue490: include pytest_load_initial_conftests in documentation
10403 and improve docstring.
10404
10405 - fix issue472: clarify that ``pytest.config.getvalue()`` cannot work
10406 if it's triggered ahead of command line parsing.
10407
10408 - merge PR123: improved integration with mock.patch decorator on tests.
10409
10410 - fix issue412: messing with stdout/stderr FD-level streams is now
10411 captured without crashes.
10412
10413 - fix issue483: trial/py33 works now properly. Thanks Daniel Grana for PR.
10414
10415 - improve example for pytest integration with "python setup.py test"
10416 which now has a generic "-a" or "--pytest-args" option where you
10417 can pass additional options as a quoted string. Thanks Trevor Bekolay.
10418
10419 - simplified internal capturing mechanism and made it more robust
10420 against tests or setups changing FD1/FD2, also better integrated
10421 now with pytest.pdb() in single tests.
10422
10423 - improvements to pytest's own test-suite leakage detection, courtesy of PRs
10424 from Marc Abramowitz
10425
10426 - fix issue492: avoid leak in test_writeorg. Thanks Marc Abramowitz.
10427
10428 - fix issue493: don't run tests in doc directory with ``python setup.py test``
10429 (use tox -e doctesting for that)
10430
10431 - fix issue486: better reporting and handling of early conftest loading failures
10432
10433 - some cleanup and simplification of internal conftest handling.
10434
10435 - work a bit harder to break reference cycles when catching exceptions.
10436 Thanks Jurko Gospodnetic.
10437
10438 - fix issue443: fix skip examples to use proper comparison. Thanks Alex
10439 Groenholm.
10440
10441 - support nose-style ``__test__`` attribute on modules, classes and
10442 functions, including unittest-style Classes. If set to False, the
10443 test will not be collected.
10444
10445 - fix issue512: show "<notset>" for arguments which might not be set
10446 in monkeypatch plugin. Improves output in documentation.
10447
10448
10449 2.5.2 (2014-01-29)
10450 ==================
10451
10452 - fix issue409 -- better interoperate with cx_freeze by not
10453 trying to import from collections.abc which causes problems
10454 for py27/cx_freeze. Thanks Wolfgang L. for reporting and tracking it down.
10455
10456 - fixed docs and code to use "pytest" instead of "py.test" almost everywhere.
10457 Thanks Jurko Gospodnetic for the complete PR.
10458
10459 - fix issue425: mention at end of "py.test -h" that --markers
10460 and --fixtures work according to specified test path (or current dir)
10461
10462 - fix issue413: exceptions with unicode attributes are now printed
10463 correctly also on python2 and with pytest-xdist runs. (the fix
10464 requires py-1.4.20)
10465
10466 - copy, cleanup and integrate py.io capture
10467 from pylib 1.4.20.dev2 (rev 13d9af95547e)
10468
10469 - address issue416: clarify docs as to conftest.py loading semantics
10470
10471 - fix issue429: comparing byte strings with non-ascii chars in assert
10472 expressions now work better. Thanks Floris Bruynooghe.
10473
10474 - make capfd/capsys.capture private, its unused and shouldn't be exposed
10475
10476
10477 2.5.1 (2013-12-17)
10478 ==================
10479
10480 - merge new documentation styling PR from Tobias Bieniek.
10481
10482 - fix issue403: allow parametrize of multiple same-name functions within
10483 a collection node. Thanks Andreas Kloeckner and Alex Gaynor for reporting
10484 and analysis.
10485
10486 - Allow parameterized fixtures to specify the ID of the parameters by
10487 adding an ids argument to pytest.fixture() and pytest.yield_fixture().
10488 Thanks Floris Bruynooghe.
10489
10490 - fix issue404 by always using the binary xml escape in the junitxml
10491 plugin. Thanks Ronny Pfannschmidt.
10492
10493 - fix issue407: fix addoption docstring to point to argparse instead of
10494 optparse. Thanks Daniel D. Wright.
10495
10496
10497
10498 2.5.0 (2013-12-12)
10499 ==================
10500
10501 - dropped python2.5 from automated release testing of pytest itself
10502 which means it's probably going to break soon (but still works
10503 with this release we believe).
10504
10505 - simplified and fixed implementation for calling finalizers when
10506 parametrized fixtures or function arguments are involved. finalization
10507 is now performed lazily at setup time instead of in the "teardown phase".
10508 While this might sound odd at first, it helps to ensure that we are
10509 correctly handling setup/teardown even in complex code. User-level code
10510 should not be affected unless it's implementing the pytest_runtest_teardown
10511 hook and expecting certain fixture instances are torn down within (very
10512 unlikely and would have been unreliable anyway).
10513
10514 - PR90: add --color=yes|no|auto option to force terminal coloring
10515 mode ("auto" is default). Thanks Marc Abramowitz.
10516
10517 - fix issue319 - correctly show unicode in assertion errors. Many
10518 thanks to Floris Bruynooghe for the complete PR. Also means
10519 we depend on py>=1.4.19 now.
10520
10521 - fix issue396 - correctly sort and finalize class-scoped parametrized
10522 tests independently from number of methods on the class.
10523
10524 - refix issue323 in a better way -- parametrization should now never
10525 cause Runtime Recursion errors because the underlying algorithm
10526 for re-ordering tests per-scope/per-fixture is not recursive
10527 anymore (it was tail-call recursive before which could lead
10528 to problems for more than >966 non-function scoped parameters).
10529
10530 - fix issue290 - there is preliminary support now for parametrizing
10531 with repeated same values (sometimes useful to test if calling
10532 a second time works as with the first time).
10533
10534 - close issue240 - document precisely how pytest module importing
10535 works, discuss the two common test directory layouts, and how it
10536 interacts with :pep:`420`\-namespace packages.
10537
10538 - fix issue246 fix finalizer order to be LIFO on independent fixtures
10539 depending on a parametrized higher-than-function scoped fixture.
10540 (was quite some effort so please bear with the complexity of this sentence :)
10541 Thanks Ralph Schmitt for the precise failure example.
10542
10543 - fix issue244 by implementing special index for parameters to only use
10544 indices for parametrized test ids
10545
10546 - fix issue287 by running all finalizers but saving the exception
10547 from the first failing finalizer and re-raising it so teardown will
10548 still have failed. We reraise the first failing exception because
10549 it might be the cause for other finalizers to fail.
10550
10551 - fix ordering when mock.patch or other standard decorator-wrappings
10552 are used with test methods. This fixes issue346 and should
10553 help with random "xdist" collection failures. Thanks to
10554 Ronny Pfannschmidt and Donald Stufft for helping to isolate it.
10555
10556 - fix issue357 - special case "-k" expressions to allow for
10557 filtering with simple strings that are not valid python expressions.
10558 Examples: "-k 1.3" matches all tests parametrized with 1.3.
10559 "-k None" filters all tests that have "None" in their name
10560 and conversely "-k 'not None'".
10561 Previously these examples would raise syntax errors.
10562
10563 - fix issue384 by removing the trial support code
10564 since the unittest compat enhancements allow
10565 trial to handle it on its own
10566
10567 - don't hide an ImportError when importing a plugin produces one.
10568 fixes issue375.
10569
10570 - fix issue275 - allow usefixtures and autouse fixtures
10571 for running doctest text files.
10572
10573 - fix issue380 by making --resultlog only rely on longrepr instead
10574 of the "reprcrash" attribute which only exists sometimes.
10575
10576 - address issue122: allow @pytest.fixture(params=iterator) by exploding
10577 into a list early on.
10578
10579 - fix pexpect-3.0 compatibility for pytest's own tests.
10580 (fixes issue386)
10581
10582 - allow nested parametrize-value markers, thanks James Lan for the PR.
10583
10584 - fix unicode handling with new monkeypatch.setattr(import_path, value)
10585 API. Thanks Rob Dennis. Fixes issue371.
10586
10587 - fix unicode handling with junitxml, fixes issue368.
10588
10589 - In assertion rewriting mode on Python 2, fix the detection of coding
10590 cookies. See issue #330.
10591
10592 - make "--runxfail" turn imperative pytest.xfail calls into no ops
10593 (it already did neutralize pytest.mark.xfail markers)
10594
10595 - refine pytest / pkg_resources interactions: The AssertionRewritingHook
10596 :pep:`302` compliant loader now registers itself with setuptools/pkg_resources
10597 properly so that the pkg_resources.resource_stream method works properly.
10598 Fixes issue366. Thanks for the investigations and full PR to Jason R. Coombs.
10599
10600 - pytestconfig fixture is now session-scoped as it is the same object during the
10601 whole test run. Fixes issue370.
10602
10603 - avoid one surprising case of marker malfunction/confusion::
10604
10605 @pytest.mark.some(lambda arg: ...)
10606 def test_function():
10607
10608 would not work correctly because pytest assumes @pytest.mark.some
10609 gets a function to be decorated already. We now at least detect if this
10610 arg is a lambda and thus the example will work. Thanks Alex Gaynor
10611 for bringing it up.
10612
10613 - xfail a test on pypy that checks wrong encoding/ascii (pypy does
10614 not error out). fixes issue385.
10615
10616 - internally make varnames() deal with classes's __init__,
10617 although it's not needed by pytest itself atm. Also
10618 fix caching. Fixes issue376.
10619
10620 - fix issue221 - handle importing of namespace-package with no
10621 __init__.py properly.
10622
10623 - refactor internal FixtureRequest handling to avoid monkeypatching.
10624 One of the positive user-facing effects is that the "request" object
10625 can now be used in closures.
10626
10627 - fixed version comparison in pytest.importskip(modname, minverstring)
10628
10629 - fix issue377 by clarifying in the nose-compat docs that pytest
10630 does not duplicate the unittest-API into the "plain" namespace.
10631
10632 - fix verbose reporting for @mock'd test functions
10633
10634 2.4.2 (2013-10-04)
10635 ==================
10636
10637 - on Windows require colorama and a newer py lib so that py.io.TerminalWriter()
10638 now uses colorama instead of its own ctypes hacks. (fixes issue365)
10639 thanks Paul Moore for bringing it up.
10640
10641 - fix "-k" matching of tests where "repr" and "attr" and other names would
10642 cause wrong matches because of an internal implementation quirk
10643 (don't ask) which is now properly implemented. fixes issue345.
10644
10645 - avoid tmpdir fixture to create too long filenames especially
10646 when parametrization is used (issue354)
10647
10648 - fix pytest-pep8 and pytest-flakes / pytest interactions
10649 (collection names in mark plugin was assuming an item always
10650 has a function which is not true for those plugins etc.)
10651 Thanks Andi Zeidler.
10652
10653 - introduce node.get_marker/node.add_marker API for plugins
10654 like pytest-pep8 and pytest-flakes to avoid the messy
10655 details of the node.keywords pseudo-dicts. Adapted
10656 docs.
10657
10658 - remove attempt to "dup" stdout at startup as it's icky.
10659 the normal capturing should catch enough possibilities
10660 of tests messing up standard FDs.
10661
10662 - add pluginmanager.do_configure(config) as a link to
10663 config.do_configure() for plugin-compatibility
10664
10665 2.4.1 (2013-10-02)
10666 ==================
10667
10668 - When using parser.addoption() unicode arguments to the
10669 "type" keyword should also be converted to the respective types.
10670 thanks Floris Bruynooghe, @dnozay. (fixes issue360 and issue362)
10671
10672 - fix dotted filename completion when using argcomplete
10673 thanks Anthon van der Neuth. (fixes issue361)
10674
10675 - fix regression when a 1-tuple ("arg",) is used for specifying
10676 parametrization (the values of the parametrization were passed
10677 nested in a tuple). Thanks Donald Stufft.
10678
10679 - merge doc typo fixes, thanks Andy Dirnberger
10680
10681 2.4
10682 ===
10683
10684 known incompatibilities:
10685
10686 - if calling --genscript from python2.7 or above, you only get a
10687 standalone script which works on python2.7 or above. Use Python2.6
10688 to also get a python2.5 compatible version.
10689
10690 - all xunit-style teardown methods (nose-style, pytest-style,
10691 unittest-style) will not be called if the corresponding setup method failed,
10692 see issue322 below.
10693
10694 - the pytest_plugin_unregister hook wasn't ever properly called
10695 and there is no known implementation of the hook - so it got removed.
10696
10697 - pytest.fixture-decorated functions cannot be generators (i.e. use
10698 yield) anymore. This change might be reversed in 2.4.1 if it causes
10699 unforeseen real-life issues. However, you can always write and return
10700 an inner function/generator and change the fixture consumer to iterate
10701 over the returned generator. This change was done in lieu of the new
10702 ``pytest.yield_fixture`` decorator, see below.
10703
10704 new features:
10705
10706 - experimentally introduce a new ``pytest.yield_fixture`` decorator
10707 which accepts exactly the same parameters as pytest.fixture but
10708 mandates a ``yield`` statement instead of a ``return statement`` from
10709 fixture functions. This allows direct integration with "with-style"
10710 context managers in fixture functions and generally avoids registering
10711 of finalization callbacks in favour of treating the "after-yield" as
10712 teardown code. Thanks Andreas Pelme, Vladimir Keleshev, Floris
10713 Bruynooghe, Ronny Pfannschmidt and many others for discussions.
10714
10715 - allow boolean expression directly with skipif/xfail
10716 if a "reason" is also specified. Rework skipping documentation
10717 to recommend "condition as booleans" because it prevents surprises
10718 when importing markers between modules. Specifying conditions
10719 as strings will remain fully supported.
10720
10721 - reporting: color the last line red or green depending if
10722 failures/errors occurred or everything passed. thanks Christian
10723 Theunert.
10724
10725 - make "import pdb ; pdb.set_trace()" work natively wrt capturing (no
10726 "-s" needed anymore), making ``pytest.set_trace()`` a mere shortcut.
10727
10728 - fix issue181: --pdb now also works on collect errors (and
10729 on internal errors) . This was implemented by a slight internal
10730 refactoring and the introduction of a new hook
10731 ``pytest_exception_interact`` hook (see next item).
10732
10733 - fix issue341: introduce new experimental hook for IDEs/terminals to
10734 intercept debugging: ``pytest_exception_interact(node, call, report)``.
10735
10736 - new monkeypatch.setattr() variant to provide a shorter
10737 invocation for patching out classes/functions from modules:
10738
10739 monkeypatch.setattr("requests.get", myfunc)
10740
10741 will replace the "get" function of the "requests" module with ``myfunc``.
10742
10743 - fix issue322: tearDownClass is not run if setUpClass failed. Thanks
10744 Mathieu Agopian for the initial fix. Also make all of pytest/nose
10745 finalizer mimic the same generic behaviour: if a setupX exists and
10746 fails, don't run teardownX. This internally introduces a new method
10747 "node.addfinalizer()" helper which can only be called during the setup
10748 phase of a node.
10749
10750 - simplify pytest.mark.parametrize() signature: allow to pass a
10751 CSV-separated string to specify argnames. For example:
10752 ``pytest.mark.parametrize("input,expected", [(1,2), (2,3)])``
10753 works as well as the previous:
10754 ``pytest.mark.parametrize(("input", "expected"), ...)``.
10755
10756 - add support for setUpModule/tearDownModule detection, thanks Brian Okken.
10757
10758 - integrate tab-completion on options through use of "argcomplete".
10759 Thanks Anthon van der Neut for the PR.
10760
10761 - change option names to be hyphen-separated long options but keep the
10762 old spelling backward compatible. py.test -h will only show the
10763 hyphenated version, for example "--collect-only" but "--collectonly"
10764 will remain valid as well (for backward-compat reasons). Many thanks to
10765 Anthon van der Neut for the implementation and to Hynek Schlawack for
10766 pushing us.
10767
10768 - fix issue 308 - allow to mark/xfail/skip individual parameter sets
10769 when parametrizing. Thanks Brianna Laugher.
10770
10771 - call new experimental pytest_load_initial_conftests hook to allow
10772 3rd party plugins to do something before a conftest is loaded.
10773
10774 Bug fixes:
10775
10776 - fix issue358 - capturing options are now parsed more properly
10777 by using a new parser.parse_known_args method.
10778
10779 - pytest now uses argparse instead of optparse (thanks Anthon) which
10780 means that "argparse" is added as a dependency if installing into python2.6
10781 environments or below.
10782
10783 - fix issue333: fix a case of bad unittest/pytest hook interaction.
10784
10785 - PR27: correctly handle nose.SkipTest during collection. Thanks
10786 Antonio Cuni, Ronny Pfannschmidt.
10787
10788 - fix issue355: junitxml puts name="pytest" attribute to testsuite tag.
10789
10790 - fix issue336: autouse fixture in plugins should work again.
10791
10792 - fix issue279: improve object comparisons on assertion failure
10793 for standard datatypes and recognise collections.abc. Thanks to
10794 Brianna Laugher and Mathieu Agopian.
10795
10796 - fix issue317: assertion rewriter support for the is_package method
10797
10798 - fix issue335: document py.code.ExceptionInfo() object returned
10799 from pytest.raises(), thanks Mathieu Agopian.
10800
10801 - remove implicit distribute_setup support from setup.py.
10802
10803 - fix issue305: ignore any problems when writing pyc files.
10804
10805 - SO-17664702: call fixture finalizers even if the fixture function
10806 partially failed (finalizers would not always be called before)
10807
10808 - fix issue320 - fix class scope for fixtures when mixed with
10809 module-level functions. Thanks Anatoly Bubenkoff.
10810
10811 - you can specify "-q" or "-qq" to get different levels of "quieter"
10812 reporting (thanks Katarzyna Jachim)
10813
10814 - fix issue300 - Fix order of conftest loading when starting py.test
10815 in a subdirectory.
10816
10817 - fix issue323 - sorting of many module-scoped arg parametrizations
10818
10819 - make sessionfinish hooks execute with the same cwd-context as at
10820 session start (helps fix plugin behaviour which write output files
10821 with relative path such as pytest-cov)
10822
10823 - fix issue316 - properly reference collection hooks in docs
10824
10825 - fix issue 306 - cleanup of -k/-m options to only match markers/test
10826 names/keywords respectively. Thanks Wouter van Ackooy.
10827
10828 - improved doctest counting for doctests in python modules --
10829 files without any doctest items will not show up anymore
10830 and doctest examples are counted as separate test items.
10831 thanks Danilo Bellini.
10832
10833 - fix issue245 by depending on the released py-1.4.14
10834 which fixes py.io.dupfile to work with files with no
10835 mode. Thanks Jason R. Coombs.
10836
10837 - fix junitxml generation when test output contains control characters,
10838 addressing issue267, thanks Jaap Broekhuizen
10839
10840 - fix issue338: honor --tb style for setup/teardown errors as well. Thanks Maho.
10841
10842 - fix issue307 - use yaml.safe_load in example, thanks Mark Eichin.
10843
10844 - better parametrize error messages, thanks Brianna Laugher
10845
10846 - pytest_terminal_summary(terminalreporter) hooks can now use
10847 ".section(title)" and ".line(msg)" methods to print extra
10848 information at the end of a test run.
10849
10850 2.3.5 (2013-04-30)
10851 ==================
10852
10853 - fix issue169: respect --tb=style with setup/teardown errors as well.
10854
10855 - never consider a fixture function for test function collection
10856
10857 - allow re-running of test items / helps to fix pytest-reruntests plugin
10858 and also help to keep less fixture/resource references alive
10859
10860 - put captured stdout/stderr into junitxml output even for passing tests
10861 (thanks Adam Goucher)
10862
10863 - Issue 265 - integrate nose setup/teardown with setupstate
10864 so it doesn't try to teardown if it did not setup
10865
10866 - issue 271 - don't write junitxml on worker nodes
10867
10868 - Issue 274 - don't try to show full doctest example
10869 when doctest does not know the example location
10870
10871 - issue 280 - disable assertion rewriting on buggy CPython 2.6.0
10872
10873 - inject "getfixture()" helper to retrieve fixtures from doctests,
10874 thanks Andreas Zeidler
10875
10876 - issue 259 - when assertion rewriting, be consistent with the default
10877 source encoding of ASCII on Python 2
10878
10879 - issue 251 - report a skip instead of ignoring classes with init
10880
10881 - issue250 unicode/str mixes in parametrization names and values now works
10882
10883 - issue257, assertion-triggered compilation of source ending in a
10884 comment line doesn't blow up in python2.5 (fixed through py>=1.4.13.dev6)
10885
10886 - fix --genscript option to generate standalone scripts that also
10887 work with python3.3 (importer ordering)
10888
10889 - issue171 - in assertion rewriting, show the repr of some
10890 global variables
10891
10892 - fix option help for "-k"
10893
10894 - move long description of distribution into README.rst
10895
10896 - improve docstring for metafunc.parametrize()
10897
10898 - fix bug where using capsys with pytest.set_trace() in a test
10899 function would break when looking at capsys.readouterr()
10900
10901 - allow to specify prefixes starting with "_" when
10902 customizing python_functions test discovery. (thanks Graham Horler)
10903
10904 - improve PYTEST_DEBUG tracing output by putting
10905 extra data on a new lines with additional indent
10906
10907 - ensure OutcomeExceptions like skip/fail have initialized exception attributes
10908
10909 - issue 260 - don't use nose special setup on plain unittest cases
10910
10911 - fix issue134 - print the collect errors that prevent running specified test items
10912
10913 - fix issue266 - accept unicode in MarkEvaluator expressions
10914
10915 2.3.4 (2012-11-20)
10916 ==================
10917
10918 - yielded test functions will now have autouse-fixtures active but
10919 cannot accept fixtures as funcargs - it's anyway recommended to
10920 rather use the post-2.0 parametrize features instead of yield, see:
10921 http://pytest.org/en/stable/example/how-to/parametrize.html
10922 - fix autouse-issue where autouse-fixtures would not be discovered
10923 if defined in an a/conftest.py file and tests in a/tests/test_some.py
10924 - fix issue226 - LIFO ordering for fixture teardowns
10925 - fix issue224 - invocations with >256 char arguments now work
10926 - fix issue91 - add/discuss package/directory level setups in example
10927 - allow to dynamically define markers via
10928 item.keywords[...]=assignment integrating with "-m" option
10929 - make "-k" accept an expressions the same as with "-m" so that one
10930 can write: -k "name1 or name2" etc. This is a slight incompatibility
10931 if you used special syntax like "TestClass.test_method" which you now
10932 need to write as -k "TestClass and test_method" to match a certain
10933 method in a certain test class.
10934
10935 2.3.3 (2012-11-06)
10936 ==================
10937
10938 - fix issue214 - parse modules that contain special objects like e. g.
10939 flask's request object which blows up on getattr access if no request
10940 is active. thanks Thomas Waldmann.
10941
10942 - fix issue213 - allow to parametrize with values like numpy arrays that
10943 do not support an __eq__ operator
10944
10945 - fix issue215 - split test_python.org into multiple files
10946
10947 - fix issue148 - @unittest.skip on classes is now recognized and avoids
10948 calling setUpClass/tearDownClass, thanks Pavel Repin
10949
10950 - fix issue209 - reintroduce python2.4 support by depending on newer
10951 pylib which re-introduced statement-finding for pre-AST interpreters
10952
10953 - nose support: only call setup if it's a callable, thanks Andrew
10954 Taumoefolau
10955
10956 - fix issue219 - add py2.4-3.3 classifiers to TROVE list
10957
10958 - in tracebacks *,** arg values are now shown next to normal arguments
10959 (thanks Manuel Jacob)
10960
10961 - fix issue217 - support mock.patch with pytest's fixtures - note that
10962 you need either mock-1.0.1 or the python3.3 builtin unittest.mock.
10963
10964 - fix issue127 - improve documentation for pytest_addoption() and
10965 add a ``config.getoption(name)`` helper function for consistency.
10966
10967 2.3.2 (2012-10-25)
10968 ==================
10969
10970 - fix issue208 and fix issue29 use new py version to avoid long pauses
10971 when printing tracebacks in long modules
10972
10973 - fix issue205 - conftests in subdirs customizing
10974 pytest_pycollect_makemodule and pytest_pycollect_makeitem
10975 now work properly
10976
10977 - fix teardown-ordering for parametrized setups
10978
10979 - fix issue127 - better documentation for pytest_addoption
10980 and related objects.
10981
10982 - fix unittest behaviour: TestCase.runtest only called if there are
10983 test methods defined
10984
10985 - improve trial support: don't collect its empty
10986 unittest.TestCase.runTest() method
10987
10988 - "python setup.py test" now works with pytest itself
10989
10990 - fix/improve internal/packaging related bits:
10991
10992 - exception message check of test_nose.py now passes on python33 as well
10993
10994 - issue206 - fix test_assertrewrite.py to work when a global
10995 PYTHONDONTWRITEBYTECODE=1 is present
10996
10997 - add tox.ini to pytest distribution so that ignore-dirs and others config
10998 bits are properly distributed for maintainers who run pytest-own tests
10999
11000 2.3.1 (2012-10-20)
11001 ==================
11002
11003 - fix issue202 - fix regression: using "self" from fixture functions now
11004 works as expected (it's the same "self" instance that a test method
11005 which uses the fixture sees)
11006
11007 - skip pexpect using tests (test_pdb.py mostly) on freebsd* systems
11008 due to pexpect not supporting it properly (hanging)
11009
11010 - link to web pages from --markers output which provides help for
11011 pytest.mark.* usage.
11012
11013 2.3.0 (2012-10-19)
11014 ==================
11015
11016 - fix issue202 - better automatic names for parametrized test functions
11017 - fix issue139 - introduce @pytest.fixture which allows direct scoping
11018 and parametrization of funcarg factories.
11019 - fix issue198 - conftest fixtures were not found on windows32 in some
11020 circumstances with nested directory structures due to path manipulation issues
11021 - fix issue193 skip test functions with were parametrized with empty
11022 parameter sets
11023 - fix python3.3 compat, mostly reporting bits that previously depended
11024 on dict ordering
11025 - introduce re-ordering of tests by resource and parametrization setup
11026 which takes precedence to the usual file-ordering
11027 - fix issue185 monkeypatching time.time does not cause pytest to fail
11028 - fix issue172 duplicate call of pytest.fixture decoratored setup_module
11029 functions
11030 - fix junitxml=path construction so that if tests change the
11031 current working directory and the path is a relative path
11032 it is constructed correctly from the original current working dir.
11033 - fix "python setup.py test" example to cause a proper "errno" return
11034 - fix issue165 - fix broken doc links and mention stackoverflow for FAQ
11035 - catch unicode-issues when writing failure representations
11036 to terminal to prevent the whole session from crashing
11037 - fix xfail/skip confusion: a skip-mark or an imperative pytest.skip
11038 will now take precedence before xfail-markers because we
11039 can't determine xfail/xpass status in case of a skip. see also:
11040 http://stackoverflow.com/questions/11105828/in-py-test-when-i-explicitly-skip-a-test-that-is-marked-as-xfail-how-can-i-get
11041
11042 - always report installed 3rd party plugins in the header of a test run
11043
11044 - fix issue160: a failing setup of an xfail-marked tests should
11045 be reported as xfail (not xpass)
11046
11047 - fix issue128: show captured output when capsys/capfd are used
11048
11049 - fix issue179: properly show the dependency chain of factories
11050
11051 - pluginmanager.register(...) now raises ValueError if the
11052 plugin has been already registered or the name is taken
11053
11054 - fix issue159: improve https://docs.pytest.org/en/6.0.1/faq.html
11055 especially with respect to the "magic" history, also mention
11056 pytest-django, trial and unittest integration.
11057
11058 - make request.keywords and node.keywords writable. All descendant
11059 collection nodes will see keyword values. Keywords are dictionaries
11060 containing markers and other info.
11061
11062 - fix issue 178: xml binary escapes are now wrapped in py.xml.raw
11063
11064 - fix issue 176: correctly catch the builtin AssertionError
11065 even when we replaced AssertionError with a subclass on the
11066 python level
11067
11068 - factory discovery no longer fails with magic global callables
11069 that provide no sane __code__ object (mock.call for example)
11070
11071 - fix issue 182: testdir.inprocess_run now considers passed plugins
11072
11073 - fix issue 188: ensure sys.exc_info is clear on python2
11074 before calling into a test
11075
11076 - fix issue 191: add unittest TestCase runTest method support
11077 - fix issue 156: monkeypatch correctly handles class level descriptors
11078
11079 - reporting refinements:
11080
11081 - pytest_report_header now receives a "startdir" so that
11082 you can use startdir.bestrelpath(yourpath) to show
11083 nice relative path
11084
11085 - allow plugins to implement both pytest_report_header and
11086 pytest_sessionstart (sessionstart is invoked first).
11087
11088 - don't show deselected reason line if there is none
11089
11090 - py.test -vv will show all of assert comparisons instead of truncating
11091
11092 2.2.4 (2012-05-22)
11093 ==================
11094
11095 - fix error message for rewritten assertions involving the % operator
11096 - fix issue 126: correctly match all invalid xml characters for junitxml
11097 binary escape
11098 - fix issue with unittest: now @unittest.expectedFailure markers should
11099 be processed correctly (you can also use @pytest.mark markers)
11100 - document integration with the extended distribute/setuptools test commands
11101 - fix issue 140: properly get the real functions
11102 of bound classmethods for setup/teardown_class
11103 - fix issue #141: switch from the deceased paste.pocoo.org to bpaste.net
11104 - fix issue #143: call unconfigure/sessionfinish always when
11105 configure/sessionstart where called
11106 - fix issue #144: better mangle test ids to junitxml classnames
11107 - upgrade distribute_setup.py to 0.6.27
11108
11109 2.2.3 (2012-02-05)
11110 ==================
11111
11112 - fix uploaded package to only include necessary files
11113
11114 2.2.2 (2012-02-05)
11115 ==================
11116
11117 - fix issue101: wrong args to unittest.TestCase test function now
11118 produce better output
11119 - fix issue102: report more useful errors and hints for when a
11120 test directory was renamed and some pyc/__pycache__ remain
11121 - fix issue106: allow parametrize to be applied multiple times
11122 e.g. from module, class and at function level.
11123 - fix issue107: actually perform session scope finalization
11124 - don't check in parametrize if indirect parameters are funcarg names
11125 - add chdir method to monkeypatch funcarg
11126 - fix crash resulting from calling monkeypatch undo a second time
11127 - fix issue115: make --collectonly robust against early failure
11128 (missing files/directories)
11129 - "-qq --collectonly" now shows only files and the number of tests in them
11130 - "-q --collectonly" now shows test ids
11131 - allow adding of attributes to test reports such that it also works
11132 with distributed testing (no upgrade of pytest-xdist needed)
11133
11134 2.2.1 (2011-12-16)
11135 ==================
11136
11137 - fix issue99 (in pytest and py) internallerrors with resultlog now
11138 produce better output - fixed by normalizing pytest_internalerror
11139 input arguments.
11140 - fix issue97 / traceback issues (in pytest and py) improve traceback output
11141 in conjunction with jinja2 and cython which hack tracebacks
11142 - fix issue93 (in pytest and pytest-xdist) avoid "delayed teardowns":
11143 the final test in a test node will now run its teardown directly
11144 instead of waiting for the end of the session. Thanks Dave Hunt for
11145 the good reporting and feedback. The pytest_runtest_protocol as well
11146 as the pytest_runtest_teardown hooks now have "nextitem" available
11147 which will be None indicating the end of the test run.
11148 - fix collection crash due to unknown-source collected items, thanks
11149 to Ralf Schmitt (fixed by depending on a more recent pylib)
11150
11151 2.2.0 (2011-11-18)
11152 ==================
11153
11154 - fix issue90: introduce eager tearing down of test items so that
11155 teardown function are called earlier.
11156 - add an all-powerful metafunc.parametrize function which allows to
11157 parametrize test function arguments in multiple steps and therefore
11158 from independent plugins and places.
11159 - add a @pytest.mark.parametrize helper which allows to easily
11160 call a test function with different argument values
11161 - Add examples to the "parametrize" example page, including a quick port
11162 of Test scenarios and the new parametrize function and decorator.
11163 - introduce registration for "pytest.mark.*" helpers via ini-files
11164 or through plugin hooks. Also introduce a "--strict" option which
11165 will treat unregistered markers as errors
11166 allowing to avoid typos and maintain a well described set of markers
11167 for your test suite. See examples at http://pytest.org/en/stable/how-to/mark.html
11168 and its links.
11169 - issue50: introduce "-m marker" option to select tests based on markers
11170 (this is a stricter and more predictable version of '-k' in that "-m"
11171 only matches complete markers and has more obvious rules for and/or
11172 semantics.
11173 - new feature to help optimizing the speed of your tests:
11174 --durations=N option for displaying N slowest test calls
11175 and setup/teardown methods.
11176 - fix issue87: --pastebin now works with python3
11177 - fix issue89: --pdb with unexpected exceptions in doctest work more sensibly
11178 - fix and cleanup pytest's own test suite to not leak FDs
11179 - fix issue83: link to generated funcarg list
11180 - fix issue74: pyarg module names are now checked against imp.find_module false positives
11181 - fix compatibility with twisted/trial-11.1.0 use cases
11182 - simplify Node.listchain
11183 - simplify junitxml output code by relying on py.xml
11184 - add support for skip properties on unittest classes and functions
11185
11186 2.1.3 (2011-10-18)
11187 ==================
11188
11189 - fix issue79: assertion rewriting failed on some comparisons in boolops
11190 - correctly handle zero length arguments (a la pytest '')
11191 - fix issue67 / junitxml now contains correct test durations, thanks ronny
11192 - fix issue75 / skipping test failure on jython
11193 - fix issue77 / Allow assertrepr_compare hook to apply to a subset of tests
11194
11195 2.1.2 (2011-09-24)
11196 ==================
11197
11198 - fix assertion rewriting on files with windows newlines on some Python versions
11199 - refine test discovery by package/module name (--pyargs), thanks Florian Mayer
11200 - fix issue69 / assertion rewriting fixed on some boolean operations
11201 - fix issue68 / packages now work with assertion rewriting
11202 - fix issue66: use different assertion rewriting caches when the -O option is passed
11203 - don't try assertion rewriting on Jython, use reinterp
11204
11205 2.1.1
11206 =====
11207
11208 - fix issue64 / pytest.set_trace now works within pytest_generate_tests hooks
11209 - fix issue60 / fix error conditions involving the creation of __pycache__
11210 - fix issue63 / assertion rewriting on inserts involving strings containing '%'
11211 - fix assertion rewriting on calls with a ** arg
11212 - don't cache rewritten modules if bytecode generation is disabled
11213 - fix assertion rewriting in read-only directories
11214 - fix issue59: provide system-out/err tags for junitxml output
11215 - fix issue61: assertion rewriting on boolean operations with 3 or more operands
11216 - you can now build a man page with "cd doc ; make man"
11217
11218 2.1.0 (2011-07-09)
11219 ==================
11220
11221 - fix issue53 call nosestyle setup functions with correct ordering
11222 - fix issue58 and issue59: new assertion code fixes
11223 - merge Benjamin's assertionrewrite branch: now assertions
11224 for test modules on python 2.6 and above are done by rewriting
11225 the AST and saving the pyc file before the test module is imported.
11226 see doc/assert.txt for more info.
11227 - fix issue43: improve doctests with better traceback reporting on
11228 unexpected exceptions
11229 - fix issue47: timing output in junitxml for test cases is now correct
11230 - fix issue48: typo in MarkInfo repr leading to exception
11231 - fix issue49: avoid confusing error when initialization partially fails
11232 - fix issue44: env/username expansion for junitxml file path
11233 - show releaselevel information in test runs for pypy
11234 - reworked doc pages for better navigation and PDF generation
11235 - report KeyboardInterrupt even if interrupted during session startup
11236 - fix issue 35 - provide PDF doc version and download link from index page
11237
11238 2.0.3 (2011-05-11)
11239 ==================
11240
11241 - fix issue38: nicer tracebacks on calls to hooks, particularly early
11242 configure/sessionstart ones
11243
11244 - fix missing skip reason/meta information in junitxml files, reported
11245 via http://lists.idyll.org/pipermail/testing-in-python/2011-March/003928.html
11246
11247 - fix issue34: avoid collection failure with "test" prefixed classes
11248 deriving from object.
11249
11250 - don't require zlib (and other libs) for genscript plugin without
11251 --genscript actually being used.
11252
11253 - speed up skips (by not doing a full traceback representation
11254 internally)
11255
11256 - fix issue37: avoid invalid characters in junitxml's output
11257
11258 2.0.2 (2011-03-09)
11259 ==================
11260
11261 - tackle issue32 - speed up test runs of very quick test functions
11262 by reducing the relative overhead
11263
11264 - fix issue30 - extended xfail/skipif handling and improved reporting.
11265 If you have a syntax error in your skip/xfail
11266 expressions you now get nice error reports.
11267
11268 Also you can now access module globals from xfail/skipif
11269 expressions so that this for example works now::
11270
11271 import pytest
11272 import mymodule
11273 @pytest.mark.skipif("mymodule.__version__[0] == "1")
11274 def test_function():
11275 pass
11276
11277 This will not run the test function if the module's version string
11278 does not start with a "1". Note that specifying a string instead
11279 of a boolean expressions allows py.test to report meaningful information
11280 when summarizing a test run as to what conditions lead to skipping
11281 (or xfail-ing) tests.
11282
11283 - fix issue28 - setup_method and pytest_generate_tests work together
11284 The setup_method fixture method now gets called also for
11285 test function invocations generated from the pytest_generate_tests
11286 hook.
11287
11288 - fix issue27 - collectonly and keyword-selection (-k) now work together
11289 Also, if you do "py.test --collectonly -q" you now get a flat list
11290 of test ids that you can use to paste to the py.test commandline
11291 in order to execute a particular test.
11292
11293 - fix issue25 avoid reported problems with --pdb and python3.2/encodings output
11294
11295 - fix issue23 - tmpdir argument now works on Python3.2 and WindowsXP
11296 Starting with Python3.2 os.symlink may be supported. By requiring
11297 a newer py lib version the py.path.local() implementation acknowledges
11298 this.
11299
11300 - fixed typos in the docs (thanks Victor Garcia, Brianna Laugher) and particular
11301 thanks to Laura Creighton who also reviewed parts of the documentation.
11302
11303 - fix slightly wrong output of verbose progress reporting for classes
11304 (thanks Amaury)
11305
11306 - more precise (avoiding of) deprecation warnings for node.Class|Function accesses
11307
11308 - avoid std unittest assertion helper code in tracebacks (thanks Ronny)
11309
11310 2.0.1 (2011-02-07)
11311 ==================
11312
11313 - refine and unify initial capturing so that it works nicely
11314 even if the logging module is used on an early-loaded conftest.py
11315 file or plugin.
11316 - allow to omit "()" in test ids to allow for uniform test ids
11317 as produced by Alfredo's nice pytest.vim plugin.
11318 - fix issue12 - show plugin versions with "--version" and
11319 "--traceconfig" and also document how to add extra information
11320 to reporting test header
11321 - fix issue17 (import-* reporting issue on python3) by
11322 requiring py>1.4.0 (1.4.1 is going to include it)
11323 - fix issue10 (numpy arrays truth checking) by refining
11324 assertion interpretation in py lib
11325 - fix issue15: make nose compatibility tests compatible
11326 with python3 (now that nose-1.0 supports python3)
11327 - remove somewhat surprising "same-conftest" detection because
11328 it ignores conftest.py when they appear in several subdirs.
11329 - improve assertions ("not in"), thanks Floris Bruynooghe
11330 - improve behaviour/warnings when running on top of "python -OO"
11331 (assertions and docstrings are turned off, leading to potential
11332 false positives)
11333 - introduce a pytest_cmdline_processargs(args) hook
11334 to allow dynamic computation of command line arguments.
11335 This fixes a regression because py.test prior to 2.0
11336 allowed to set command line options from conftest.py
11337 files which so far pytest-2.0 only allowed from ini-files now.
11338 - fix issue7: assert failures in doctest modules.
11339 unexpected failures in doctests will not generally
11340 show nicer, i.e. within the doctest failing context.
11341 - fix issue9: setup/teardown functions for an xfail-marked
11342 test will report as xfail if they fail but report as normally
11343 passing (not xpassing) if they succeed. This only is true
11344 for "direct" setup/teardown invocations because teardown_class/
11345 teardown_module cannot closely relate to a single test.
11346 - fix issue14: no logging errors at process exit
11347 - refinements to "collecting" output on non-ttys
11348 - refine internal plugin registration and --traceconfig output
11349 - introduce a mechanism to prevent/unregister plugins from the
11350 command line, see http://pytest.org/en/stable/how-to/plugins.html#cmdunregister
11351 - activate resultlog plugin by default
11352 - fix regression wrt yielded tests which due to the
11353 collection-before-running semantics were not
11354 setup as with pytest 1.3.4. Note, however, that
11355 the recommended and much cleaner way to do test
11356 parameterization remains the "pytest_generate_tests"
11357 mechanism, see the docs.
11358
11359 2.0.0 (2010-11-25)
11360 ==================
11361
11362 - pytest-2.0 is now its own package and depends on pylib-2.0
11363 - new ability: python -m pytest / python -m pytest.main ability
11364 - new python invocation: pytest.main(args, plugins) to load
11365 some custom plugins early.
11366 - try harder to run unittest test suites in a more compatible manner
11367 by deferring setup/teardown semantics to the unittest package.
11368 also work harder to run twisted/trial and Django tests which
11369 should now basically work by default.
11370 - introduce a new way to set config options via ini-style files,
11371 by default setup.cfg and tox.ini files are searched. The old
11372 ways (certain environment variables, dynamic conftest.py reading
11373 is removed).
11374 - add a new "-q" option which decreases verbosity and prints a more
11375 nose/unittest-style "dot" output.
11376 - fix issue135 - marks now work with unittest test cases as well
11377 - fix issue126 - introduce py.test.set_trace() to trace execution via
11378 PDB during the running of tests even if capturing is ongoing.
11379 - fix issue123 - new "python -m py.test" invocation for py.test
11380 (requires Python 2.5 or above)
11381 - fix issue124 - make reporting more resilient against tests opening
11382 files on filedescriptor 1 (stdout).
11383 - fix issue109 - sibling conftest.py files will not be loaded.
11384 (and Directory collectors cannot be customized anymore from a Directory's
11385 conftest.py - this needs to happen at least one level up).
11386 - introduce (customizable) assertion failure representations and enhance
11387 output on assertion failures for comparisons and other cases (Floris Bruynooghe)
11388 - nose-plugin: pass through type-signature failures in setup/teardown
11389 functions instead of not calling them (Ed Singleton)
11390 - remove py.test.collect.Directory (follows from a major refactoring
11391 and simplification of the collection process)
11392 - majorly reduce py.test core code, shift function/python testing to own plugin
11393 - fix issue88 (finding custom test nodes from command line arg)
11394 - refine 'tmpdir' creation, will now create basenames better associated
11395 with test names (thanks Ronny)
11396 - "xpass" (unexpected pass) tests don't cause exitcode!=0
11397 - fix issue131 / issue60 - importing doctests in __init__ files used as namespace packages
11398 - fix issue93 stdout/stderr is captured while importing conftest.py
11399 - fix bug: unittest collected functions now also can have "pytestmark"
11400 applied at class/module level
11401 - add ability to use "class" level for cached_setup helper
11402 - fix strangeness: mark.* objects are now immutable, create new instances
11403
11404 1.3.4 (2010-09-14)
11405 ==================
11406
11407 - fix issue111: improve install documentation for windows
11408 - fix issue119: fix custom collectability of __init__.py as a module
11409 - fix issue116: --doctestmodules work with __init__.py files as well
11410 - fix issue115: unify internal exception passthrough/catching/GeneratorExit
11411 - fix issue118: new --tb=native for presenting cpython-standard exceptions
11412
11413 1.3.3 (2010-07-30)
11414 ==================
11415
11416 - fix issue113: assertion representation problem with triple-quoted strings
11417 (and possibly other cases)
11418 - make conftest loading detect that a conftest file with the same
11419 content was already loaded, avoids surprises in nested directory structures
11420 which can be produced e.g. by Hudson. It probably removes the need to use
11421 --confcutdir in most cases.
11422 - fix terminal coloring for win32
11423 (thanks Michael Foord for reporting)
11424 - fix weirdness: make terminal width detection work on stdout instead of stdin
11425 (thanks Armin Ronacher for reporting)
11426 - remove trailing whitespace in all py/text distribution files
11427
11428 1.3.2 (2010-07-08)
11429 ==================
11430
11431 **New features**
11432
11433 - fix issue103: introduce py.test.raises as context manager, examples::
11434
11435 with py.test.raises(ZeroDivisionError):
11436 x = 0
11437 1 / x
11438
11439 with py.test.raises(RuntimeError) as excinfo:
11440 call_something()
11441
11442 # you may do extra checks on excinfo.value|type|traceback here
11443
11444 (thanks Ronny Pfannschmidt)
11445
11446 - Funcarg factories can now dynamically apply a marker to a
11447 test invocation. This is for example useful if a factory
11448 provides parameters to a test which are expected-to-fail::
11449
11450 def pytest_funcarg__arg(request):
11451 request.applymarker(py.test.mark.xfail(reason="flaky config"))
11452 ...
11453
11454 def test_function(arg):
11455 ...
11456
11457 - improved error reporting on collection and import errors. This makes
11458 use of a more general mechanism, namely that for custom test item/collect
11459 nodes ``node.repr_failure(excinfo)`` is now uniformly called so that you can
11460 override it to return a string error representation of your choice
11461 which is going to be reported as a (red) string.
11462
11463 - introduce '--junitprefix=STR' option to prepend a prefix
11464 to all reports in the junitxml file.
11465
11466 **Bug fixes**
11467
11468 - make tests and the ``pytest_recwarn`` plugin in particular fully compatible
11469 to Python2.7 (if you use the ``recwarn`` funcarg warnings will be enabled so that
11470 you can properly check for their existence in a cross-python manner).
11471 - refine --pdb: ignore xfailed tests, unify its TB-reporting and
11472 don't display failures again at the end.
11473 - fix assertion interpretation with the ** operator (thanks Benjamin Peterson)
11474 - fix issue105 assignment on the same line as a failing assertion (thanks Benjamin Peterson)
11475 - fix issue104 proper escaping for test names in junitxml plugin (thanks anonymous)
11476 - fix issue57 -f|--looponfail to work with xpassing tests (thanks Ronny)
11477 - fix issue92 collectonly reporter and --pastebin (thanks Benjamin Peterson)
11478 - fix py.code.compile(source) to generate unique filenames
11479 - fix assertion re-interp problems on PyPy, by deferring code
11480 compilation to the (overridable) Frame.eval class. (thanks Amaury Forgeot)
11481 - fix py.path.local.pyimport() to work with directories
11482 - streamline py.path.local.mkdtemp implementation and usage
11483 - don't print empty lines when showing junitxml-filename
11484 - add optional boolean ignore_errors parameter to py.path.local.remove
11485 - fix terminal writing on win32/python2.4
11486 - py.process.cmdexec() now tries harder to return properly encoded unicode objects
11487 on all python versions
11488 - install plain py.test/py.which scripts also for Jython, this helps to
11489 get canonical script paths in virtualenv situations
11490 - make path.bestrelpath(path) return ".", note that when calling
11491 X.bestrelpath the assumption is that X is a directory.
11492 - make initial conftest discovery ignore "--" prefixed arguments
11493 - fix resultlog plugin when used in a multicpu/multihost xdist situation
11494 (thanks Jakub Gustak)
11495 - perform distributed testing related reporting in the xdist-plugin
11496 rather than having dist-related code in the generic py.test
11497 distribution
11498 - fix homedir detection on Windows
11499 - ship distribute_setup.py version 0.6.13
11500
11501 1.3.1 (2010-05-25)
11502 ==================
11503
11504 **New features**
11505
11506 - issue91: introduce new py.test.xfail(reason) helper
11507 to imperatively mark a test as expected to fail. Can
11508 be used from within setup and test functions. This is
11509 useful especially for parametrized tests when certain
11510 configurations are expected-to-fail. In this case the
11511 declarative approach with the @py.test.mark.xfail cannot
11512 be used as it would mark all configurations as xfail.
11513
11514 - issue102: introduce new --maxfail=NUM option to stop
11515 test runs after NUM failures. This is a generalization
11516 of the '-x' or '--exitfirst' option which is now equivalent
11517 to '--maxfail=1'. Both '-x' and '--maxfail' will
11518 now also print a line near the end indicating the Interruption.
11519
11520 - issue89: allow py.test.mark decorators to be used on classes
11521 (class decorators were introduced with python2.6) and
11522 also allow to have multiple markers applied at class/module level
11523 by specifying a list.
11524
11525 - improve and refine letter reporting in the progress bar:
11526 . pass
11527 f failed test
11528 s skipped tests (reminder: use for dependency/platform mismatch only)
11529 x xfailed test (test that was expected to fail)
11530 X xpassed test (test that was expected to fail but passed)
11531
11532 You can use any combination of 'fsxX' with the '-r' extended
11533 reporting option. The xfail/xpass results will show up as
11534 skipped tests in the junitxml output - which also fixes
11535 issue99.
11536
11537 - make py.test.cmdline.main() return the exitstatus instead of raising
11538 SystemExit and also allow it to be called multiple times. This of
11539 course requires that your application and tests are properly teared
11540 down and don't have global state.
11541
11542 **Bug Fixes**
11543
11544 - improved traceback presentation:
11545 - improved and unified reporting for "--tb=short" option
11546 - Errors during test module imports are much shorter, (using --tb=short style)
11547 - raises shows shorter more relevant tracebacks
11548 - --fulltrace now more systematically makes traces longer / inhibits cutting
11549
11550 - improve support for raises and other dynamically compiled code by
11551 manipulating python's linecache.cache instead of the previous
11552 rather hacky way of creating custom code objects. This makes
11553 it seamlessly work on Jython and PyPy where it previously didn't.
11554
11555 - fix issue96: make capturing more resilient against Control-C
11556 interruptions (involved somewhat substantial refactoring
11557 to the underlying capturing functionality to avoid race
11558 conditions).
11559
11560 - fix chaining of conditional skipif/xfail decorators - so it works now
11561 as expected to use multiple @py.test.mark.skipif(condition) decorators,
11562 including specific reporting which of the conditions lead to skipping.
11563
11564 - fix issue95: late-import zlib so that it's not required
11565 for general py.test startup.
11566
11567 - fix issue94: make reporting more robust against bogus source code
11568 (and internally be more careful when presenting unexpected byte sequences)
11569
11570
11571 1.3.0 (2010-05-05)
11572 ==================
11573
11574 - deprecate --report option in favour of a new shorter and easier to
11575 remember -r option: it takes a string argument consisting of any
11576 combination of 'xfsX' characters. They relate to the single chars
11577 you see during the dotted progress printing and will print an extra line
11578 per test at the end of the test run. This extra line indicates the exact
11579 position or test ID that you directly paste to the py.test cmdline in order
11580 to re-run a particular test.
11581
11582 - allow external plugins to register new hooks via the new
11583 pytest_addhooks(pluginmanager) hook. The new release of
11584 the pytest-xdist plugin for distributed and looponfailing
11585 testing requires this feature.
11586
11587 - add a new pytest_ignore_collect(path, config) hook to allow projects and
11588 plugins to define exclusion behaviour for their directory structure -
11589 for example you may define in a conftest.py this method::
11590
11591 def pytest_ignore_collect(path):
11592 return path.check(link=1)
11593
11594 to prevent even a collection try of any tests in symlinked dirs.
11595
11596 - new pytest_pycollect_makemodule(path, parent) hook for
11597 allowing customization of the Module collection object for a
11598 matching test module.
11599
11600 - extend and refine xfail mechanism:
11601 ``@py.test.mark.xfail(run=False)`` do not run the decorated test
11602 ``@py.test.mark.xfail(reason="...")`` prints the reason string in xfail summaries
11603 specifying ``--runxfail`` on command line virtually ignores xfail markers
11604
11605 - expose (previously internal) commonly useful methods:
11606 py.io.get_terminal_with() -> return terminal width
11607 py.io.ansi_print(...) -> print colored/bold text on linux/win32
11608 py.io.saferepr(obj) -> return limited representation string
11609
11610 - expose test outcome related exceptions as py.test.skip.Exception,
11611 py.test.raises.Exception etc., useful mostly for plugins
11612 doing special outcome interpretation/tweaking
11613
11614 - (issue85) fix junitxml plugin to handle tests with non-ascii output
11615
11616 - fix/refine python3 compatibility (thanks Benjamin Peterson)
11617
11618 - fixes for making the jython/win32 combination work, note however:
11619 jython2.5.1/win32 does not provide a command line launcher, see
11620 https://bugs.jython.org/issue1491 . See pylib install documentation
11621 for how to work around.
11622
11623 - fixes for handling of unicode exception values and unprintable objects
11624
11625 - (issue87) fix unboundlocal error in assertionold code
11626
11627 - (issue86) improve documentation for looponfailing
11628
11629 - refine IO capturing: stdin-redirect pseudo-file now has a NOP close() method
11630
11631 - ship distribute_setup.py version 0.6.10
11632
11633 - added links to the new capturelog and coverage plugins
11634
11635
11636 1.2.0 (2010-01-18)
11637 ==================
11638
11639 - refined usage and options for "py.cleanup"::
11640
11641 py.cleanup # remove "*.pyc" and "*$py.class" (jython) files
11642 py.cleanup -e .swp -e .cache # also remove files with these extensions
11643 py.cleanup -s # remove "build" and "dist" directory next to setup.py files
11644 py.cleanup -d # also remove empty directories
11645 py.cleanup -a # synonym for "-s -d -e 'pip-log.txt'"
11646 py.cleanup -n # dry run, only show what would be removed
11647
11648 - add a new option "py.test --funcargs" which shows available funcargs
11649 and their help strings (docstrings on their respective factory function)
11650 for a given test path
11651
11652 - display a short and concise traceback if a funcarg lookup fails
11653
11654 - early-load "conftest.py" files in non-dot first-level sub directories.
11655 allows to conveniently keep and access test-related options in a ``test``
11656 subdir and still add command line options.
11657
11658 - fix issue67: new super-short traceback-printing option: "--tb=line" will print a single line for each failing (python) test indicating its filename, lineno and the failure value
11659
11660 - fix issue78: always call python-level teardown functions even if the
11661 according setup failed. This includes refinements for calling setup_module/class functions
11662 which will now only be called once instead of the previous behaviour where they'd be called
11663 multiple times if they raise an exception (including a Skipped exception). Any exception
11664 will be re-corded and associated with all tests in the according module/class scope.
11665
11666 - fix issue63: assume <40 columns to be a bogus terminal width, default to 80
11667
11668 - fix pdb debugging to be in the correct frame on raises-related errors
11669
11670 - update apipkg.py to fix an issue where recursive imports might
11671 unnecessarily break importing
11672
11673 - fix plugin links
11674
11675 1.1.1 (2009-11-24)
11676 ==================
11677
11678 - moved dist/looponfailing from py.test core into a new
11679 separately released pytest-xdist plugin.
11680
11681 - new junitxml plugin: --junitxml=path will generate a junit style xml file
11682 which is processable e.g. by the Hudson CI system.
11683
11684 - new option: --genscript=path will generate a standalone py.test script
11685 which will not need any libraries installed. thanks to Ralf Schmitt.
11686
11687 - new option: --ignore will prevent specified path from collection.
11688 Can be specified multiple times.
11689
11690 - new option: --confcutdir=dir will make py.test only consider conftest
11691 files that are relative to the specified dir.
11692
11693 - new funcarg: "pytestconfig" is the pytest config object for access
11694 to command line args and can now be easily used in a test.
11695
11696 - install ``py.test`` and ``py.which`` with a ``-$VERSION`` suffix to
11697 disambiguate between Python3, python2.X, Jython and PyPy installed versions.
11698
11699 - new "pytestconfig" funcarg allows access to test config object
11700
11701 - new "pytest_report_header" hook can return additional lines
11702 to be displayed at the header of a test run.
11703
11704 - (experimental) allow "py.test path::name1::name2::..." for pointing
11705 to a test within a test collection directly. This might eventually
11706 evolve as a full substitute to "-k" specifications.
11707
11708 - streamlined plugin loading: order is now as documented in
11709 customize.html: setuptools, ENV, commandline, conftest.
11710 also setuptools entry point names are turned to canonical names ("pytest_*")
11711
11712 - automatically skip tests that need 'capfd' but have no os.dup
11713
11714 - allow pytest_generate_tests to be defined in classes as well
11715
11716 - deprecate usage of 'disabled' attribute in favour of pytestmark
11717 - deprecate definition of Directory, Module, Class and Function nodes
11718 in conftest.py files. Use pytest collect hooks instead.
11719
11720 - collection/item node specific runtest/collect hooks are only called exactly
11721 on matching conftest.py files, i.e. ones which are exactly below
11722 the filesystem path of an item
11723
11724 - change: the first pytest_collect_directory hook to return something
11725 will now prevent further hooks to be called.
11726
11727 - change: figleaf plugin now requires --figleaf to run. Also
11728 change its long command line options to be a bit shorter (see py.test -h).
11729
11730 - change: pytest doctest plugin is now enabled by default and has a
11731 new option --doctest-glob to set a pattern for file matches.
11732
11733 - change: remove internal py._* helper vars, only keep py._pydir
11734
11735 - robustify capturing to survive if custom pytest_runtest_setup
11736 code failed and prevented the capturing setup code from running.
11737
11738 - make py.test.* helpers provided by default plugins visible early -
11739 works transparently both for pydoc and for interactive sessions
11740 which will regularly see e.g. py.test.mark and py.test.importorskip.
11741
11742 - simplify internal plugin manager machinery
11743 - simplify internal collection tree by introducing a RootCollector node
11744
11745 - fix assert reinterpreation that sees a call containing "keyword=..."
11746
11747 - fix issue66: invoke pytest_sessionstart and pytest_sessionfinish
11748 hooks on worker nodes during dist-testing, report module/session teardown
11749 hooks correctly.
11750
11751 - fix issue65: properly handle dist-testing if no
11752 execnet/py lib installed remotely.
11753
11754 - skip some install-tests if no execnet is available
11755
11756 - fix docs, fix internal bin/ script generation
11757
11758
11759 1.1.0 (2009-11-05)
11760 ==================
11761
11762 - introduce automatic plugin registration via 'pytest11'
11763 entrypoints via setuptools' pkg_resources.iter_entry_points
11764
11765 - fix py.test dist-testing to work with execnet >= 1.0.0b4
11766
11767 - re-introduce py.test.cmdline.main() for better backward compatibility
11768
11769 - svn paths: fix a bug with path.check(versioned=True) for svn paths,
11770 allow '%' in svn paths, make svnwc.update() default to interactive mode
11771 like in 1.0.x and add svnwc.update(interactive=False) to inhibit interaction.
11772
11773 - refine distributed tarball to contain test and no pyc files
11774
11775 - try harder to have deprecation warnings for py.compat.* accesses
11776 report a correct location
11777
11778 1.0.3
11779 =====
11780
11781 * adjust and improve docs
11782
11783 * remove py.rest tool and internal namespace - it was
11784 never really advertised and can still be used with
11785 the old release if needed. If there is interest
11786 it could be revived into its own tool i guess.
11787
11788 * fix issue48 and issue59: raise an Error if the module
11789 from an imported test file does not seem to come from
11790 the filepath - avoids "same-name" confusion that has
11791 been reported repeatedly
11792
11793 * merged Ronny's nose-compatibility hacks: now
11794 nose-style setup_module() and setup() functions are
11795 supported
11796
11797 * introduce generalized py.test.mark function marking
11798
11799 * reshuffle / refine command line grouping
11800
11801 * deprecate parser.addgroup in favour of getgroup which creates option group
11802
11803 * add --report command line option that allows to control showing of skipped/xfailed sections
11804
11805 * generalized skipping: a new way to mark python functions with skipif or xfail
11806 at function, class and modules level based on platform or sys-module attributes.
11807
11808 * extend py.test.mark decorator to allow for positional args
11809
11810 * introduce and test "py.cleanup -d" to remove empty directories
11811
11812 * fix issue #59 - robustify unittest test collection
11813
11814 * make bpython/help interaction work by adding an __all__ attribute
11815 to ApiModule, cleanup initpkg
11816
11817 * use MIT license for pylib, add some contributors
11818
11819 * remove py.execnet code and substitute all usages with 'execnet' proper
11820
11821 * fix issue50 - cached_setup now caches more to expectations
11822 for test functions with multiple arguments.
11823
11824 * merge Jarko's fixes, issue #45 and #46
11825
11826 * add the ability to specify a path for py.lookup to search in
11827
11828 * fix a funcarg cached_setup bug probably only occurring
11829 in distributed testing and "module" scope with teardown.
11830
11831 * many fixes and changes for making the code base python3 compatible,
11832 many thanks to Benjamin Peterson for helping with this.
11833
11834 * consolidate builtins implementation to be compatible with >=2.3,
11835 add helpers to ease keeping 2 and 3k compatible code
11836
11837 * deprecate py.compat.doctest|subprocess|textwrap|optparse
11838
11839 * deprecate py.magic.autopath, remove py/magic directory
11840
11841 * move pytest assertion handling to py/code and a pytest_assertion
11842 plugin, add "--no-assert" option, deprecate py.magic namespaces
11843 in favour of (less) py.code ones.
11844
11845 * consolidate and cleanup py/code classes and files
11846
11847 * cleanup py/misc, move tests to bin-for-dist
11848
11849 * introduce delattr/delitem/delenv methods to py.test's monkeypatch funcarg
11850
11851 * consolidate py.log implementation, remove old approach.
11852
11853 * introduce py.io.TextIO and py.io.BytesIO for distinguishing between
11854 text/unicode and byte-streams (uses underlying standard lib io.*
11855 if available)
11856
11857 * make py.unittest_convert helper script available which converts "unittest.py"
11858 style files into the simpler assert/direct-test-classes py.test/nosetests
11859 style. The script was written by Laura Creighton.
11860
11861 * simplified internal localpath implementation
11862
11863 1.0.2 (2009-08-27)
11864 ==================
11865
11866 * fixing packaging issues, triggered by fedora redhat packaging,
11867 also added doc, examples and contrib dirs to the tarball.
11868
11869 * added a documentation link to the new django plugin.
11870
11871 1.0.1 (2009-08-19)
11872 ==================
11873
11874 * added a 'pytest_nose' plugin which handles nose.SkipTest,
11875 nose-style function/method/generator setup/teardown and
11876 tries to report functions correctly.
11877
11878 * capturing of unicode writes or encoded strings to sys.stdout/err
11879 work better, also terminalwriting was adapted and somewhat
11880 unified between windows and linux.
11881
11882 * improved documentation layout and content a lot
11883
11884 * added a "--help-config" option to show conftest.py / ENV-var names for
11885 all longopt cmdline options, and some special conftest.py variables.
11886 renamed 'conf_capture' conftest setting to 'option_capture' accordingly.
11887
11888 * fix issue #27: better reporting on non-collectable items given on commandline
11889 (e.g. pyc files)
11890
11891 * fix issue #33: added --version flag (thanks Benjamin Peterson)
11892
11893 * fix issue #32: adding support for "incomplete" paths to wcpath.status()
11894
11895 * "Test" prefixed classes are *not* collected by default anymore if they
11896 have an __init__ method
11897
11898 * monkeypatch setenv() now accepts a "prepend" parameter
11899
11900 * improved reporting of collection error tracebacks
11901
11902 * simplified multicall mechanism and plugin architecture,
11903 renamed some internal methods and argnames
11904
11905 1.0.0 (2009-08-04)
11906 ==================
11907
11908 * more terse reporting try to show filesystem path relatively to current dir
11909 * improve xfail output a bit
11910
11911 1.0.0b9 (2009-07-31)
11912 ====================
11913
11914 * cleanly handle and report final teardown of test setup
11915
11916 * fix svn-1.6 compat issue with py.path.svnwc().versioned()
11917 (thanks Wouter Vanden Hove)
11918
11919 * setup/teardown or collection problems now show as ERRORs
11920 or with big "E"'s in the progress lines. they are reported
11921 and counted separately.
11922
11923 * dist-testing: properly handle test items that get locally
11924 collected but cannot be collected on the remote side - often
11925 due to platform/dependency reasons
11926
11927 * simplified py.test.mark API - see keyword plugin documentation
11928
11929 * integrate better with logging: capturing now by default captures
11930 test functions and their immediate setup/teardown in a single stream
11931
11932 * capsys and capfd funcargs now have a readouterr() and a close() method
11933 (underlyingly py.io.StdCapture/FD objects are used which grew a
11934 readouterr() method as well to return snapshots of captured out/err)
11935
11936 * make assert-reinterpretation work better with comparisons not
11937 returning bools (reported with numpy from thanks maciej fijalkowski)
11938
11939 * reworked per-test output capturing into the pytest_iocapture.py plugin
11940 and thus removed capturing code from config object
11941
11942 * item.repr_failure(excinfo) instead of item.repr_failure(excinfo, outerr)
11943
11944
11945 1.0.0b8 (2009-07-22)
11946 ====================
11947
11948 * pytest_unittest-plugin is now enabled by default
11949
11950 * introduced pytest_keyboardinterrupt hook and
11951 refined pytest_sessionfinish hooked, added tests.
11952
11953 * workaround a buggy logging module interaction ("closing already closed
11954 files"). Thanks to Sridhar Ratnakumar for triggering.
11955
11956 * if plugins use "py.test.importorskip" for importing
11957 a dependency only a warning will be issued instead
11958 of exiting the testing process.
11959
11960 * many improvements to docs:
11961 - refined funcargs doc , use the term "factory" instead of "provider"
11962 - added a new talk/tutorial doc page
11963 - better download page
11964 - better plugin docstrings
11965 - added new plugins page and automatic doc generation script
11966
11967 * fixed teardown problem related to partially failing funcarg setups
11968 (thanks MrTopf for reporting), "pytest_runtest_teardown" is now
11969 always invoked even if the "pytest_runtest_setup" failed.
11970
11971 * tweaked doctest output for docstrings in py modules,
11972 thanks Radomir.
11973
11974 1.0.0b7
11975 =======
11976
11977 * renamed py.test.xfail back to py.test.mark.xfail to avoid
11978 two ways to decorate for xfail
11979
11980 * re-added py.test.mark decorator for setting keywords on functions
11981 (it was actually documented so removing it was not nice)
11982
11983 * remove scope-argument from request.addfinalizer() because
11984 request.cached_setup has the scope arg. TOOWTDI.
11985
11986 * perform setup finalization before reporting failures
11987
11988 * apply modified patches from Andreas Kloeckner to allow
11989 test functions to have no func_code (#22) and to make
11990 "-k" and function keywords work (#20)
11991
11992 * apply patch from Daniel Peolzleithner (issue #23)
11993
11994 * resolve issue #18, multiprocessing.Manager() and
11995 redirection clash
11996
11997 * make __name__ == "__channelexec__" for remote_exec code
11998
11999 1.0.0b3 (2009-06-19)
12000 ====================
12001
12002 * plugin classes are removed: one now defines
12003 hooks directly in conftest.py or global pytest_*.py
12004 files.
12005
12006 * added new pytest_namespace(config) hook that allows
12007 to inject helpers directly to the py.test.* namespace.
12008
12009 * documented and refined many hooks
12010
12011 * added new style of generative tests via
12012 pytest_generate_tests hook that integrates
12013 well with function arguments.
12014
12015
12016 1.0.0b1
12017 =======
12018
12019 * introduced new "funcarg" setup method,
12020 see doc/test/funcarg.txt
12021
12022 * introduced plugin architecture and many
12023 new py.test plugins, see
12024 doc/test/plugins.txt
12025
12026 * teardown_method is now guaranteed to get
12027 called after a test method has run.
12028
12029 * new method: py.test.importorskip(mod,minversion)
12030 will either import or call py.test.skip()
12031
12032 * completely revised internal py.test architecture
12033
12034 * new py.process.ForkedFunc object allowing to
12035 fork execution of a function to a sub process
12036 and getting a result back.
12037
12038 XXX lots of things missing here XXX
12039
12040 0.9.2
12041 =====
12042
12043 * refined installation and metadata, created new setup.py,
12044 now based on setuptools/ez_setup (thanks to Ralf Schmitt
12045 for his support).
12046
12047 * improved the way of making py.* scripts available in
12048 windows environments, they are now added to the
12049 Scripts directory as ".cmd" files.
12050
12051 * py.path.svnwc.status() now is more complete and
12052 uses xml output from the 'svn' command if available
12053 (Guido Wesdorp)
12054
12055 * fix for py.path.svn* to work with svn 1.5
12056 (Chris Lamb)
12057
12058 * fix path.relto(otherpath) method on windows to
12059 use normcase for checking if a path is relative.
12060
12061 * py.test's traceback is better parseable from editors
12062 (follows the filenames:LINENO: MSG convention)
12063 (thanks to Osmo Salomaa)
12064
12065 * fix to javascript-generation, "py.test --runbrowser"
12066 should work more reliably now
12067
12068 * removed previously accidentally added
12069 py.test.broken and py.test.notimplemented helpers.
12070
12071 * there now is a py.__version__ attribute
12072
12073 0.9.1
12074 =====
12075
12076 This is a fairly complete list of v0.9.1, which can
12077 serve as a reference for developers.
12078
12079 * allowing + signs in py.path.svn urls [39106]
12080 * fixed support for Failed exceptions without excinfo in py.test [39340]
12081 * added support for killing processes for Windows (as well as platforms that
12082 support os.kill) in py.misc.killproc [39655]
12083 * added setup/teardown for generative tests to py.test [40702]
12084 * added detection of FAILED TO LOAD MODULE to py.test [40703, 40738, 40739]
12085 * fixed problem with calling .remove() on wcpaths of non-versioned files in
12086 py.path [44248]
12087 * fixed some import and inheritance issues in py.test [41480, 44648, 44655]
12088 * fail to run greenlet tests when pypy is available, but without stackless
12089 [45294]
12090 * small fixes in rsession tests [45295]
12091 * fixed issue with 2.5 type representations in py.test [45483, 45484]
12092 * made that internal reporting issues displaying is done atomically in py.test
12093 [45518]
12094 * made that non-existing files are ignored by the py.lookup script [45519]
12095 * improved exception name creation in py.test [45535]
12096 * made that less threads are used in execnet [merge in 45539]
12097 * removed lock required for atomic reporting issue displaying in py.test
12098 [45545]
12099 * removed globals from execnet [45541, 45547]
12100 * refactored cleanup mechanics, made that setDaemon is set to 1 to make atexit
12101 get called in 2.5 (py.execnet) [45548]
12102 * fixed bug in joining threads in py.execnet's servemain [45549]
12103 * refactored py.test.rsession tests to not rely on exact output format anymore
12104 [45646]
12105 * using repr() on test outcome [45647]
12106 * added 'Reason' classes for py.test.skip() [45648, 45649]
12107 * killed some unnecessary sanity check in py.test.collect [45655]
12108 * avoid using os.tmpfile() in py.io.fdcapture because on Windows it's only
12109 usable by Administrators [45901]
12110 * added support for locking and non-recursive commits to py.path.svnwc [45994]
12111 * locking files in py.execnet to prevent CPython from segfaulting [46010]
12112 * added export() method to py.path.svnurl
12113 * fixed -d -x in py.test [47277]
12114 * fixed argument concatenation problem in py.path.svnwc [49423]
12115 * restore py.test behaviour that it exits with code 1 when there are failures
12116 [49974]
12117 * don't fail on html files that don't have an accompanying .txt file [50606]
12118 * fixed 'utestconvert.py < input' [50645]
12119 * small fix for code indentation in py.code.source [50755]
12120 * fix _docgen.py documentation building [51285]
12121 * improved checks for source representation of code blocks in py.test [51292]
12122 * added support for passing authentication to py.path.svn* objects [52000,
12123 52001]
12124 * removed sorted() call for py.apigen tests in favour of [].sort() to support
12125 Python 2.3 [52481]