changelog.rst (413102B)
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 we named the news folder changelog 20 21 22 .. only:: changelog_towncrier_draft 23 24 .. The 'changelog_towncrier_draft' tag is included by our 'tox -e docs', 25 but not on readthedocs. 26 27 .. include:: _changelog_towncrier_draft.rst 28 29 .. towncrier release notes start 30 31 pytest 8.2.1 (2024-05-19) 32 ========================= 33 34 Improvements 35 ------------ 36 37 - `#12334 <https://github.com/pytest-dev/pytest/issues/12334>`_: Support for Python 3.13 (beta1 at the time of writing). 38 39 40 41 Bug Fixes 42 --------- 43 44 - `#12120 <https://github.com/pytest-dev/pytest/issues/12120>`_: Fix `PermissionError` crashes arising from directories which are not selected on the command-line. 45 46 47 - `#12191 <https://github.com/pytest-dev/pytest/issues/12191>`_: Keyboard interrupts and system exits are now properly handled during the test collection. 48 49 50 - `#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. 51 52 53 - `#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``. 54 55 56 57 Trivial/Internal Changes 58 ------------------------ 59 60 - `#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. 61 62 63 pytest 8.2.0 (2024-04-27) 64 ========================= 65 66 Breaking Changes 67 ---------------- 68 69 - `#12089 <https://github.com/pytest-dev/pytest/pull/12089>`_: pytest now requires that :class:`unittest.TestCase` subclasses can be instantiated freely using ``MyTestCase('runTest')``. 70 71 If the class doesn't allow this, you may see an error during collection such as ``AttributeError: 'MyTestCase' object has no attribute 'runTest'``. 72 73 Classes which do not override ``__init__``, or do not access the test method in ``__init__`` using ``getattr`` or similar, are unaffected. 74 75 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>`_. 76 Alternatively, consider using :meth:`setUp <unittest.TestCase.setUp>` instead of ``__init__``. 77 78 If you run into this issue using ``tornado.AsyncTestCase``, please see `issue 12263 <https://github.com/pytest-dev/pytest/issues/12263>`_. 79 80 If you run into this issue using an abstract ``TestCase`` subclass, please see `issue 12275 <https://github.com/pytest-dev/pytest/issues/12275>`_. 81 82 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. 83 84 Deprecations 85 ------------ 86 87 - `#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: 88 89 - :hook:`pytest_ignore_collect` - the ``path`` parameter - use ``collection_path`` instead. 90 - :hook:`pytest_collect_file` - the ``path`` parameter - use ``file_path`` instead. 91 - :hook:`pytest_pycollect_makemodule` - the ``path`` parameter - use ``module_path`` instead. 92 - :hook:`pytest_report_header` - the ``startdir`` parameter - use ``start_path`` instead. 93 - :hook:`pytest_report_collectionfinish` - the ``startdir`` parameter - use ``start_path`` instead. 94 95 The replacement parameters are available since pytest 7.0.0. 96 The old parameters will be removed in pytest 9.0.0. 97 98 See :ref:`legacy-path-hooks-deprecated` for more details. 99 100 101 102 Features 103 -------- 104 105 - `#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. 106 107 See :ref:`Read arguments from file <args-from-file>` for details. 108 109 110 111 Improvements 112 ------------ 113 114 - `#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`. 115 116 The warning can be suppressed by passing ``exc_type=ImportError`` to :func:`pytest.importorskip`. 117 118 See :ref:`import-or-skip-import-error` for details. 119 120 121 - `#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. 122 123 124 - `#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. 125 126 127 - `#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). 128 129 130 - `#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. 131 132 133 134 Bug Fixes 135 --------- 136 137 - `#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'``. 138 139 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. 140 Previously it was ``None``, and all fixtures of such tests would share a single ``self``. 141 142 143 - `#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. 144 145 146 - `#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. 147 148 149 - `#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. 150 151 152 153 Trivial/Internal Changes 154 ------------------------ 155 156 - `#12069 <https://github.com/pytest-dev/pytest/issues/12069>`_: ``pluggy>=1.5.0`` is now required. 157 158 159 - `#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. 160 161 162 pytest 8.1.2 (2024-04-26) 163 ========================= 164 165 Bug Fixes 166 --------- 167 168 - `#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. 169 170 171 pytest 8.1.1 (2024-03-08) 172 ========================= 173 174 .. note:: 175 176 This release is not a usual bug fix release -- it contains features and improvements, being a follow up 177 to ``8.1.0``, which has been yanked from PyPI. 178 179 Features 180 -------- 181 182 - `#11475 <https://github.com/pytest-dev/pytest/issues/11475>`_: Added the new :confval:`consider_namespace_packages` configuration option, defaulting to ``False``. 183 184 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. 185 186 187 - `#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. 188 See :ref:`Fine-grained verbosity <pytest.fine_grained_verbosity>` for more details. 189 190 191 192 Improvements 193 ------------ 194 195 - `#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`. 196 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). 197 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. 198 199 200 - `#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 201 as the relative directory. 202 203 Previously this would raise an :class:`AssertionError`. 204 205 206 - `#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. 207 208 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``). 209 210 211 - `#11801 <https://github.com/pytest-dev/pytest/issues/11801>`_: Added the :func:`iter_parents() <_pytest.nodes.Node.iter_parents>` helper method on nodes. 212 It is similar to :func:`listchain <_pytest.nodes.Node.listchain>`, but goes from bottom to top, and returns an iterator, not a list. 213 214 215 - `#11850 <https://github.com/pytest-dev/pytest/issues/11850>`_: Added support for :data:`sys.last_exc` for post-mortem debugging on Python>=3.12. 216 217 218 - `#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``. 219 220 221 - `#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"``. 222 223 Previously, the mode was hard-coded to be ``"w"`` which truncates the file before logging. 224 225 226 - `#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. 227 Previously, only the first exception was reported. 228 229 230 231 Bug Fixes 232 --------- 233 234 - `#11475 <https://github.com/pytest-dev/pytest/issues/11475>`_: Fixed regression where ``--importmode=importlib`` would import non-test modules more than once. 235 236 237 - `#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``. 238 239 This change improves the collection tree for tests specified using ``--pyargs``, see :pull:`12043` for a comparison with pytest 8.0 and <8. 240 241 242 - `#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. 243 244 245 - `#12014 <https://github.com/pytest-dev/pytest/issues/12014>`_: Fix the ``stacklevel`` used when warning about marks used on fixtures. 246 247 248 - `#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. 249 250 251 Improved Documentation 252 ---------------------- 253 254 - `#11790 <https://github.com/pytest-dev/pytest/issues/11790>`_: Documented the retention of temporary directories created using the ``tmp_path`` fixture in more detail. 255 256 257 258 Trivial/Internal Changes 259 ------------------------ 260 261 - `#11785 <https://github.com/pytest-dev/pytest/issues/11785>`_: Some changes were made to private functions which may affect plugins which access them: 262 263 - ``FixtureManager._getautousenames()`` now takes a ``Node`` itself instead of the nodeid. 264 - ``FixtureManager.getfixturedefs()`` now takes the ``Node`` itself instead of the nodeid. 265 - The ``_pytest.nodes.iterparentnodeids()`` function is removed without replacement. 266 Prefer to traverse the node hierarchy itself instead. 267 If you really need to, copy the function from the previous pytest release. 268 269 270 - `#12069 <https://github.com/pytest-dev/pytest/issues/12069>`_: Delayed the deprecation of the following features to ``9.0.0``: 271 272 * :ref:`node-ctor-fspath-deprecation`. 273 * :ref:`legacy-path-hooks-deprecated`. 274 275 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. 276 277 This is the reason for ``8.1.0`` being yanked. 278 279 280 pytest 8.1.0 (YANKED) 281 ===================== 282 283 284 .. note:: 285 286 This release has been **yanked**: it broke some plugins without the proper warning period, due to 287 some warnings not showing up as expected. 288 289 See `#12069 <https://github.com/pytest-dev/pytest/issues/12069>`__. 290 291 292 pytest 8.0.2 (2024-02-24) 293 ========================= 294 295 Bug Fixes 296 --------- 297 298 - `#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``). 299 300 301 - `#11953 <https://github.com/pytest-dev/pytest/issues/11953>`_: Fix an ``IndexError`` crash raising from ``getstatementrange_ast``. 302 303 304 - `#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. 305 306 307 pytest 8.0.1 (2024-02-16) 308 ========================= 309 310 Bug Fixes 311 --------- 312 313 - `#11875 <https://github.com/pytest-dev/pytest/issues/11875>`_: Correctly handle errors from :func:`getpass.getuser` in Python 3.13. 314 315 316 - `#11879 <https://github.com/pytest-dev/pytest/issues/11879>`_: Fix an edge case where ``ExceptionInfo._stringify_exception`` could crash :func:`pytest.raises`. 317 318 319 - `#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__`. 320 321 322 - `#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. 323 324 325 - `#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. 326 327 328 - `#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. 329 330 331 pytest 8.0.0 (2024-01-27) 332 ========================= 333 334 Bug Fixes 335 --------- 336 337 - `#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. 338 339 340 - `#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. 341 342 343 pytest 8.0.0rc2 (2024-01-17) 344 ============================ 345 346 347 Improvements 348 ------------ 349 350 - `#11233 <https://github.com/pytest-dev/pytest/issues/11233>`_: Improvements to ``-r`` for xfailures and xpasses: 351 352 * Report tracebacks for xfailures when ``-rx`` is set. 353 * Report captured output for xpasses when ``-rX`` is set. 354 * For xpasses, add ``-`` in summary between test name and reason, to match how xfail is displayed. 355 356 - `#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. 357 358 359 Bug Fixes 360 --------- 361 362 - `#11706 <https://github.com/pytest-dev/pytest/issues/11706>`_: Fix reporting of teardown errors in higher-scoped fixtures when using `--maxfail` or `--stepwise`. 363 364 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. 365 366 367 - `#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"``. 368 This bug was introduced in pytest 8.0.0rc1. 369 370 371 - `#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 interchangably in some places in the code. 372 373 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*. 374 375 376 pytest 8.0.0rc1 (2023-12-30) 377 ============================ 378 379 Breaking Changes 380 ---------------- 381 382 Old Deprecations Are Now Errors 383 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 384 385 - `#7363 <https://github.com/pytest-dev/pytest/issues/7363>`_: **PytestRemovedIn8Warning deprecation warnings are now errors by default.** 386 387 Following our plan to remove deprecated features with as little disruption as 388 possible, all warnings of type ``PytestRemovedIn8Warning`` now generate errors 389 instead of warning messages by default. 390 391 **The affected features will be effectively removed in pytest 8.1**, so please consult the 392 :ref:`deprecations` section in the docs for directions on how to update existing code. 393 394 In the pytest ``8.0.X`` series, it is possible to change the errors back into warnings as a 395 stopgap measure by adding this to your ``pytest.ini`` file: 396 397 .. code-block:: ini 398 399 [pytest] 400 filterwarnings = 401 ignore::pytest.PytestRemovedIn8Warning 402 403 But this will stop working when pytest ``8.1`` is released. 404 405 **If you have concerns** about the removal of a specific feature, please add a 406 comment to :issue:`7363`. 407 408 409 Version Compatibility 410 ^^^^^^^^^^^^^^^^^^^^^ 411 412 - `#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/>`__. 413 414 415 - ``pluggy>=1.3.0`` is now required. 416 417 418 Collection Changes 419 ^^^^^^^^^^^^^^^^^^ 420 421 In this version we've made several breaking changes to pytest's collection phase, 422 particularly around how filesystem directories and Python packages are collected, 423 fixing deficiencies and allowing for cleanups and improvements to pytest's internals. 424 A deprecation period for these changes was not possible. 425 426 427 - `#7777 <https://github.com/pytest-dev/pytest/issues/7777>`_: Files and directories are now collected in alphabetical order jointly, unless changed by a plugin. 428 Previously, files were collected before directories. 429 See below for an example. 430 431 432 - `#8976 <https://github.com/pytest-dev/pytest/issues/8976>`_: Running `pytest pkg/__init__.py` now collects the `pkg/__init__.py` file (module) only. 433 Previously, it collected the entire `pkg` package, including other test files in the directory, but excluding tests in the `__init__.py` file itself 434 (unless :confval:`python_files` was changed to allow `__init__.py` file). 435 436 To collect the entire package, specify just the directory: `pytest pkg`. 437 438 439 - `#11137 <https://github.com/pytest-dev/pytest/issues/11137>`_: :class:`pytest.Package` is no longer a :class:`pytest.Module` or :class:`pytest.File`. 440 441 The ``Package`` collector node designates a Python package, that is, a directory with an `__init__.py` file. 442 Previously ``Package`` was a subtype of ``pytest.Module`` (which represents a single Python module), 443 the module being the `__init__.py` file. 444 This has been deemed a design mistake (see :issue:`11137` and :issue:`7777` for details). 445 446 The ``path`` property of ``Package`` nodes now points to the package directory instead of the ``__init__.py`` file. 447 448 Note that a ``Module`` node for ``__init__.py`` (which is not a ``Package``) may still exist, 449 if it is picked up during collection (e.g. if you configured :confval:`python_files` to include ``__init__.py`` files). 450 451 452 - `#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. 453 This is analogous to the existing :class:`pytest.File` for file nodes. 454 455 Changed :class:`pytest.Package` to be a subclass of :class:`pytest.Directory`. 456 A ``Package`` represents a filesystem directory which is a Python package, 457 i.e. contains an ``__init__.py`` file. 458 459 :class:`pytest.Package` now only collects files in its own directory; previously it collected recursively. 460 Sub-directories are collected as their own collector nodes, which then collect themselves, thus creating a collection tree which mirrors the filesystem hierarchy. 461 462 Added a new :class:`pytest.Dir` concrete collection node, a subclass of :class:`pytest.Directory`. 463 This node represents a filesystem directory, which is not a :class:`pytest.Package`, 464 that is, does not contain an ``__init__.py`` file. 465 Similarly to ``Package``, it only collects the files in its own directory. 466 467 :class:`pytest.Session` now only collects the initial arguments, without recursing into directories. 468 This work is now done by the :func:`recursive expansion process <pytest.Collector.collect>` of directory collector nodes. 469 470 :attr:`session.name <pytest.Session.name>` is now ``""``; previously it was the rootdir directory name. 471 This matches :attr:`session.nodeid <_pytest.nodes.Node.nodeid>` which has always been `""`. 472 473 The collection tree now contains directories/packages up to the :ref:`rootdir <rootdir>`, 474 for initial arguments that are found within the rootdir. 475 For files outside the rootdir, only the immediate directory/package is collected -- 476 note however that collecting from outside the rootdir is discouraged. 477 478 As an example, given the following filesystem tree:: 479 480 myroot/ 481 pytest.ini 482 top/ 483 ├── aaa 484 │ └── test_aaa.py 485 ├── test_a.py 486 ├── test_b 487 │ ├── __init__.py 488 │ └── test_b.py 489 ├── test_c.py 490 └── zzz 491 ├── __init__.py 492 └── test_zzz.py 493 494 the collection tree, as shown by `pytest --collect-only top/` but with the otherwise-hidden :class:`~pytest.Session` node added for clarity, 495 is now the following:: 496 497 <Session> 498 <Dir myroot> 499 <Dir top> 500 <Dir aaa> 501 <Module test_aaa.py> 502 <Function test_it> 503 <Module test_a.py> 504 <Function test_it> 505 <Package test_b> 506 <Module test_b.py> 507 <Function test_it> 508 <Module test_c.py> 509 <Function test_it> 510 <Package zzz> 511 <Module test_zzz.py> 512 <Function test_it> 513 514 Previously, it was:: 515 516 <Session> 517 <Module top/test_a.py> 518 <Function test_it> 519 <Module top/test_c.py> 520 <Function test_it> 521 <Module top/aaa/test_aaa.py> 522 <Function test_it> 523 <Package test_b> 524 <Module test_b.py> 525 <Function test_it> 526 <Package zzz> 527 <Module test_zzz.py> 528 <Function test_it> 529 530 Code/plugins which rely on a specific shape of the collection tree might need to update. 531 532 533 - `#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`). 534 535 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. 536 537 538 Other breaking changes 539 ^^^^^^^^^^^^^^^^^^^^^^ 540 541 These are breaking changes where deprecation was not possible. 542 543 544 - `#11282 <https://github.com/pytest-dev/pytest/issues/11282>`_: Sanitized the handling of the ``default`` parameter when defining configuration options. 545 546 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. 547 548 Now the behavior of :meth:`parser.addini <pytest.Parser.addini>` is as follows: 549 550 * 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. 551 * If ``default=None`` is passed and the option is not defined in a test session, then ``None`` will be returned, regardless of the ``type``. 552 * If neither ``default`` nor ``type`` are provided, assume ``type=str`` and return ``""`` as default (this is as per previous behavior). 553 554 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. 555 556 557 - `#11667 <https://github.com/pytest-dev/pytest/issues/11667>`_: pytest's ``setup.py`` file is removed. 558 If you relied on this file, e.g. to install pytest using ``setup.py install``, 559 please see `Why you shouldn't invoke setup.py directly <https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html#summary>`_ for alternatives. 560 561 562 - `#9288 <https://github.com/pytest-dev/pytest/issues/9288>`_: :func:`~pytest.warns` now re-emits unmatched warnings when the context 563 closes -- previously it would consume all warnings, hiding those that were not 564 matched by the function. 565 566 While this is a new feature, we announce it as a breaking change 567 because many test suites are configured to error-out on warnings, and will 568 therefore fail on the newly-re-emitted warnings. 569 570 571 - The internal ``FixtureManager.getfixtureclosure`` method has changed. Plugins which use this method or 572 which subclass ``FixtureManager`` and overwrite that method will need to adapt to the change. 573 574 575 576 Deprecations 577 ------------ 578 579 - `#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. 580 581 582 - `#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. 583 584 This will become an error in pytest 9.0. 585 586 587 588 Features and Improvements 589 ------------------------- 590 591 Improved Diffs 592 ^^^^^^^^^^^^^^ 593 594 These changes improve the diffs that pytest prints when an assertion fails. 595 Note that syntax highlighting requires the ``pygments`` package. 596 597 598 - `#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. 599 600 Python code in error reports is now syntax-highlighted as Python. 601 602 The sections in the error reports are now better separated. 603 604 605 - `#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. 606 607 Previously, the standard Python pretty printer was used to generate the output, which puts opening and closing 608 markers on the same line as the first/last entry, in addition to not having consistent indentation. 609 610 611 - `#10617 <https://github.com/pytest-dev/pytest/issues/10617>`_: Added more comprehensive set assertion rewrites for comparisons other than equality ``==``, with 612 the following operations now providing better failure messages: ``!=``, ``<=``, ``>=``, ``<``, and ``>``. 613 614 615 Separate Control For Assertion Verbosity 616 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 617 618 - `#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. 619 620 If you've ever wished that pytest always show you full diffs, but without making everything else verbose, this is for you. 621 622 See :ref:`Fine-grained verbosity <pytest.fine_grained_verbosity>` for more details. 623 624 For plugin authors, :attr:`config.get_verbosity <pytest.Config.get_verbosity>` can be used to retrieve the verbosity level for a specific verbosity type. 625 626 627 Additional Support For Exception Groups and ``__notes__`` 628 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 629 630 These changes improve pytest's support for exception groups. 631 632 633 - `#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. 634 635 See :ref:`assert-matching-exception-groups` for an example. 636 637 638 - `#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__``. 639 640 641 Custom Directory collectors 642 ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 643 644 - `#7777 <https://github.com/pytest-dev/pytest/issues/7777>`_: Added a new hook :hook:`pytest_collect_directory`, 645 which is called by filesystem-traversing collector nodes, 646 such as :class:`pytest.Session`, :class:`pytest.Dir` and :class:`pytest.Package`, 647 to create a collector node for a sub-directory. 648 It is expected to return a subclass of :class:`pytest.Directory`. 649 This hook allows plugins to :ref:`customize the collection of directories <custom directory collectors>`. 650 651 652 "New-style" Hook Wrappers 653 ^^^^^^^^^^^^^^^^^^^^^^^^^ 654 655 - `#11122 <https://github.com/pytest-dev/pytest/issues/11122>`_: pytest now uses "new-style" hook wrappers internally, available since pluggy 1.2.0. 656 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. 657 658 Plugins which want to use new-style wrappers can do so if they require ``pytest>=8``. 659 660 661 Other Improvements 662 ^^^^^^^^^^^^^^^^^^ 663 664 - `#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. 665 666 667 - `#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 668 if ``--log-file-level``, ``--log-file-format`` and ``--log-file-date-format`` are not provided respectively. 669 670 671 - `#11610 <https://github.com/pytest-dev/pytest/issues/11610>`_: Added the :func:`LogCaptureFixture.filtering() <pytest.LogCaptureFixture.filtering>` context manager which 672 adds a given :class:`logging.Filter` object to the :fixture:`caplog` fixture. 673 674 675 - `#11447 <https://github.com/pytest-dev/pytest/issues/11447>`_: :func:`pytest.deprecated_call` now also considers warnings of type :class:`FutureWarning`. 676 677 678 - `#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. 679 680 681 - `#7469 <https://github.com/pytest-dev/pytest/issues/7469>`_: :class:`~pytest.FixtureDef` is now exported as ``pytest.FixtureDef`` for typing purposes. 682 683 684 - `#11353 <https://github.com/pytest-dev/pytest/issues/11353>`_: Added typing to :class:`~pytest.PytestPluginManager`. 685 686 687 Bug Fixes 688 --------- 689 690 - `#10701 <https://github.com/pytest-dev/pytest/issues/10701>`_: :meth:`pytest.WarningsRecorder.pop` will return the most-closely-matched warning in the list, 691 rather than the first warning which is an instance of the requested type. 692 693 694 - `#11255 <https://github.com/pytest-dev/pytest/issues/11255>`_: Fixed crash on `parametrize(..., scope="package")` without a package present. 695 696 697 - `#11277 <https://github.com/pytest-dev/pytest/issues/11277>`_: Fixed a bug that when there are multiple fixtures for an indirect parameter, 698 the scope of the highest-scope fixture is picked for the parameter set, instead of that of the one with the narrowest scope. 699 700 701 - `#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 702 example, ``a, a, a0`` now results in ``a1, a2, a0`` instead of the previous (buggy) ``a0, a1, a0``. 703 This necessarily means changing nodeids where these were previously colliding, and for 704 readability adds an underscore when non-unique ids end in a number. 705 706 707 - `#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. 708 709 710 - `#11712 <https://github.com/pytest-dev/pytest/issues/11712>`_: Fixed handling ``NO_COLOR`` and ``FORCE_COLOR`` to ignore an empty value. 711 712 713 - `#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. 714 715 716 717 Improved Documentation 718 ---------------------- 719 720 - `#11011 <https://github.com/pytest-dev/pytest/issues/11011>`_: Added a warning about modifying the root logger during tests when using ``caplog``. 721 722 723 - `#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. 724 725 726 Trivial/Internal Changes 727 ------------------------ 728 729 - `#11208 <https://github.com/pytest-dev/pytest/issues/11208>`_: The (internal) ``FixtureDef.cached_result`` type has changed. 730 Now the third item ``cached_result[2]``, when set, is an exception instance instead of an exception triplet. 731 732 733 - `#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.) 734 735 :class:`~pytest.FixtureRequest` is now an abstract class which can't be instantiated directly. 736 A new concrete ``TopRequest`` subclass of ``FixtureRequest`` has been added for the ``request`` fixture in test functions, 737 as counterpart to the existing ``SubRequest`` subclass for the ``request`` fixture in fixture functions. 738 739 740 - `#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. 741 If you use ``pytester`` in combination with :func:`monkeypatch.undo() <pytest.MonkeyPatch.undo>`, the CWD might get restored. 742 Use :func:`monkeypatch.context() <pytest.MonkeyPatch.context>` instead. 743 744 745 - `#11333 <https://github.com/pytest-dev/pytest/issues/11333>`_: Corrected the spelling of ``Config.ArgsSource.INVOCATION_DIR``. 746 The previous spelling ``INCOVATION_DIR`` remains as an alias. 747 748 749 - `#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. 750 751 pytest 7.4.4 (2023-12-31) 752 ========================= 753 754 Bug Fixes 755 --------- 756 757 - `#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. 758 759 760 - `#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. 761 762 763 - `#11710 <https://github.com/pytest-dev/pytest/issues/11710>`_: Fixed tracebacks from collection errors not getting pruned. 764 765 766 - `#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. 767 768 769 770 Improved Documentation 771 ---------------------- 772 773 - `#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``. 774 775 776 pytest 7.4.3 (2023-10-24) 777 ========================= 778 779 Bug Fixes 780 --------- 781 782 - `#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. 783 784 785 - `#11239 <https://github.com/pytest-dev/pytest/issues/11239>`_: Fixed ``:=`` in asserts impacting unrelated test cases. 786 787 788 - `#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. 789 790 791 pytest 7.4.2 (2023-09-07) 792 ========================= 793 794 Bug Fixes 795 --------- 796 797 - `#11237 <https://github.com/pytest-dev/pytest/issues/11237>`_: Fix doctest collection of `functools.cached_property` objects. 798 799 800 - `#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. 801 802 803 - `#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. 804 805 806 - `#11394 <https://github.com/pytest-dev/pytest/issues/11394>`_: Fixed crash when parsing long command line arguments that might be interpreted as files. 807 808 809 810 Improved Documentation 811 ---------------------- 812 813 - `#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. 814 815 816 pytest 7.4.1 (2023-09-02) 817 ========================= 818 819 Bug Fixes 820 --------- 821 822 - `#10337 <https://github.com/pytest-dev/pytest/issues/10337>`_: Fixed bug where fake intermediate modules generated by ``--import-mode=importlib`` would not include the 823 child modules as attributes of the parent modules. 824 825 826 - `#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. 827 828 829 - `#10811 <https://github.com/pytest-dev/pytest/issues/10811>`_: Fixed issue when using ``--import-mode=importlib`` together with ``--doctest-modules`` that caused modules 830 to be imported more than once, causing problems with modules that have import side effects. 831 832 833 pytest 7.4.0 (2023-06-23) 834 ========================= 835 836 Features 837 -------- 838 839 - `#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. 840 This can replace :func:`ExceptionInfo.from_exc_info() <pytest.ExceptionInfo.from_exc_info()>` for most uses. 841 842 843 844 Improvements 845 ------------ 846 847 - `#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. 848 849 850 - `#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: 851 852 "All traceback entries are hidden. Pass `--full-trace` to see hidden and internal frames.". 853 854 Previously, the last frame of the traceback was shown, even though it was hidden. 855 856 857 - `#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. 858 859 Added ``TerminalReporter.wrap_write()`` as a helper for that. 860 861 862 - `#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``. 863 864 865 - `#11005 <https://github.com/pytest-dev/pytest/issues/11005>`_: Added the underlying exception to the cache provider's path creation and write warning messages. 866 867 868 - `#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. 869 870 871 - `#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>`. 872 Previously in such cases, `conftest.py` files would be probed all the way to the root directory of the filesystem. 873 If you are badly affected by this change, consider adding an empty config file to your desired cutoff directory, or explicitly set `--confcutdir`. 874 875 876 - `#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. 877 878 If after updating to this version you see that your `norecursedirs` setting is not being respected, 879 it means that a conftest or a plugin you use has a bad `pytest_ignore_collect` implementation. 880 Most likely, your hook returns `False` for paths it does not want to ignore, 881 which ends the processing and doesn't allow other plugins, including pytest itself, to ignore the path. 882 The fix is to return `None` instead of `False` for paths your hook doesn't want to ignore. 883 884 885 - `#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>` 886 will temporarily enable the requested ``level`` if ``level`` was disabled globally via 887 ``logging.disable(LEVEL)``. 888 889 890 891 Bug Fixes 892 --------- 893 894 - `#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``. 895 896 897 - `#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>`. 898 899 900 - `#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, 901 even when it was not utilized (e.g. when explicit paths were given on the command line). 902 Now the ``testpaths`` are only considered when they are in use. 903 904 905 - `#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). 906 907 908 - `#7781 <https://github.com/pytest-dev/pytest/issues/7781>`_: Fix writing non-encodable text to log file when using ``--debug``. 909 910 911 912 Improved Documentation 913 ---------------------- 914 915 - `#9146 <https://github.com/pytest-dev/pytest/issues/9146>`_: Improved documentation for :func:`caplog.set_level() <pytest.LogCaptureFixture.set_level>`. 916 917 918 919 Trivial/Internal Changes 920 ------------------------ 921 922 - `#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. 923 924 925 pytest 7.3.2 (2023-06-10) 926 ========================= 927 928 Bug Fixes 929 --------- 930 931 - `#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. 932 933 934 - `#10894 <https://github.com/pytest-dev/pytest/issues/10894>`_: Support for Python 3.12 (beta at the time of writing). 935 936 937 - `#10987 <https://github.com/pytest-dev/pytest/issues/10987>`_: :confval:`testpaths` is now honored to load root ``conftests``. 938 939 940 - `#10999 <https://github.com/pytest-dev/pytest/issues/10999>`_: The `monkeypatch` `setitem`/`delitem` type annotations now allow `TypedDict` arguments. 941 942 943 - `#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. 944 945 946 - `#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). 947 948 949 pytest 7.3.1 (2023-04-14) 950 ========================= 951 952 Improvements 953 ------------ 954 955 - `#10875 <https://github.com/pytest-dev/pytest/issues/10875>`_: Python 3.12 support: fixed ``RuntimeError: TestResult has no addDuration method`` when running ``unittest`` tests. 956 957 958 - `#10890 <https://github.com/pytest-dev/pytest/issues/10890>`_: Python 3.12 support: fixed ``shutil.rmtree(onerror=...)`` deprecation warning when using :fixture:`tmp_path`. 959 960 961 962 Bug Fixes 963 --------- 964 965 - `#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. 966 967 968 - `#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. 969 This reverts the change "Correctly handle ``__tracebackhide__`` for chained exceptions." introduced in version 7.3.0. 970 971 972 pytest 7.3.0 (2023-04-08) 973 ========================= 974 975 Features 976 -------- 977 978 - `#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. 979 980 981 - `#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. 982 983 984 - `#7431 <https://github.com/pytest-dev/pytest/issues/7431>`_: ``--log-disable`` CLI option added to disable individual loggers. 985 986 987 - `#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. 988 989 990 991 Improvements 992 ------------ 993 994 - `#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. 995 996 997 - `#10658 <https://github.com/pytest-dev/pytest/issues/10658>`_: Allow ``-p`` arguments to include spaces (eg: ``-p no:logging`` instead of 998 ``-pno:logging``). Mostly useful in the ``addopts`` section of the configuration 999 file. 1000 1001 1002 - `#10710 <https://github.com/pytest-dev/pytest/issues/10710>`_: Added ``start`` and ``stop`` timestamps to ``TestReport`` objects. 1003 1004 1005 - `#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. 1006 1007 1008 - `#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>__`. 1009 1010 1011 - `#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 1012 the hidden text. The line number shown has also been fixed. 1013 1014 1015 1016 Bug Fixes 1017 --------- 1018 1019 - `#10743 <https://github.com/pytest-dev/pytest/issues/10743>`_: The assertion rewriting mechanism now works correctly when assertion expressions contain the walrus operator. 1020 1021 1022 - `#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`. 1023 1024 1025 - `#1904 <https://github.com/pytest-dev/pytest/issues/1904>`_: Correctly handle ``__tracebackhide__`` for chained exceptions. 1026 NOTE: This change was reverted in version 7.3.1. 1027 1028 1029 1030 Improved Documentation 1031 ---------------------- 1032 1033 - `#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. 1034 1035 1036 1037 Trivial/Internal Changes 1038 ------------------------ 1039 1040 - `#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 1041 we at pytest all love the package dearly and would like to thank the ``attrs`` team for many years of cooperation and support, 1042 it makes sense for ``pytest`` to have as little external dependencies as possible, as this helps downstream projects. 1043 With that in mind, we have replaced the pytest's limited internal usage to use the standard library's ``dataclasses`` instead. 1044 1045 Nice diffs for ``attrs`` classes are still supported though. 1046 1047 1048 pytest 7.2.2 (2023-03-03) 1049 ========================= 1050 1051 Bug Fixes 1052 --------- 1053 1054 - `#10533 <https://github.com/pytest-dev/pytest/issues/10533>`_: Fixed :func:`pytest.approx` handling of dictionaries containing one or more values of `0.0`. 1055 1056 1057 - `#10592 <https://github.com/pytest-dev/pytest/issues/10592>`_: Fixed crash if `--cache-show` and `--help` are passed at the same time. 1058 1059 1060 - `#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. 1061 1062 1063 - `#10626 <https://github.com/pytest-dev/pytest/issues/10626>`_: Fixed crash if ``--fixtures`` and ``--help`` are passed at the same time. 1064 1065 1066 - `#10660 <https://github.com/pytest-dev/pytest/issues/10660>`_: Fixed :py:func:`pytest.raises` to return a 'ContextManager' so that type-checkers could narrow 1067 :code:`pytest.raises(...) if ... else nullcontext()` down to 'ContextManager' rather than 'object'. 1068 1069 1070 1071 Improved Documentation 1072 ---------------------- 1073 1074 - `#10690 <https://github.com/pytest-dev/pytest/issues/10690>`_: Added `CI` and `BUILD_NUMBER` environment variables to the documentation. 1075 1076 1077 - `#10721 <https://github.com/pytest-dev/pytest/issues/10721>`_: Fixed entry-points declaration in the documentation example using Hatch. 1078 1079 1080 - `#10753 <https://github.com/pytest-dev/pytest/issues/10753>`_: Changed wording of the module level skip to be very explicit 1081 about not collecting tests and not executing the rest of the module. 1082 1083 1084 pytest 7.2.1 (2023-01-13) 1085 ========================= 1086 1087 Bug Fixes 1088 --------- 1089 1090 - `#10452 <https://github.com/pytest-dev/pytest/issues/10452>`_: Fix 'importlib.abc.TraversableResources' deprecation warning in Python 3.12. 1091 1092 1093 - `#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. 1094 1095 1096 - `#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. 1097 1098 1099 - `#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. 1100 1101 1102 - `#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. 1103 1104 1105 pytest 7.2.0 (2022-10-23) 1106 ========================= 1107 1108 Deprecations 1109 ------------ 1110 1111 - `#10012 <https://github.com/pytest-dev/pytest/issues/10012>`_: Update :class:`pytest.PytestUnhandledCoroutineWarning` to a deprecation; it will raise an error in pytest 8. 1112 1113 1114 - `#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. 1115 1116 1117 - `#4562 <https://github.com/pytest-dev/pytest/issues/4562>`_: Deprecate configuring hook specs/impls using attributes/marks. 1118 1119 Instead use :py:func:`pytest.hookimpl` and :py:func:`pytest.hookspec`. 1120 For more details, see the :ref:`docs <legacy-path-hooks-deprecated>`. 1121 1122 1123 - `#9886 <https://github.com/pytest-dev/pytest/issues/9886>`_: The functionality for running tests written for ``nose`` has been officially deprecated. 1124 1125 This includes: 1126 1127 * 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. 1128 * Setup/teardown using the `@with_setup <with-setup-nose>`_ decorator. 1129 1130 For more details, consult the :ref:`deprecation docs <nose-deprecation>`. 1131 1132 .. _`with-setup-nose`: https://nose.readthedocs.io/en/latest/testing_tools.html?highlight=with_setup#nose.tools.with_setup 1133 1134 - `#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. 1135 1136 1137 Features 1138 -------- 1139 1140 - `#9897 <https://github.com/pytest-dev/pytest/issues/9897>`_: Added shell-style wildcard support to ``testpaths``. 1141 1142 1143 1144 Improvements 1145 ------------ 1146 1147 - `#10218 <https://github.com/pytest-dev/pytest/issues/10218>`_: ``@pytest.mark.parametrize()`` (and similar functions) now accepts any ``Sequence[str]`` for the argument names, 1148 instead of just ``list[str]`` and ``tuple[str, ...]``. 1149 1150 (Note that ``str``, which is itself a ``Sequence[str]``, is still treated as a 1151 comma-delimited name list, as before). 1152 1153 1154 - `#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``. 1155 1156 1157 - `#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. 1158 1159 1160 - `#8508 <https://github.com/pytest-dev/pytest/issues/8508>`_: Introduce multiline display for warning matching via :py:func:`pytest.warns` and 1161 enhance match comparison for :py:func:`pytest.ExceptionInfo.match` as returned by :py:func:`pytest.raises`. 1162 1163 1164 - `#8646 <https://github.com/pytest-dev/pytest/issues/8646>`_: Improve :py:func:`pytest.raises`. Previously passing an empty tuple would give a confusing 1165 error. We now raise immediately with a more helpful message. 1166 1167 1168 - `#9741 <https://github.com/pytest-dev/pytest/issues/9741>`_: On Python 3.11, use the standard library's :mod:`tomllib` to parse TOML. 1169 1170 `tomli` is no longer a dependency on Python 3.11. 1171 1172 1173 - `#9742 <https://github.com/pytest-dev/pytest/issues/9742>`_: Display assertion message without escaped newline characters with ``-vv``. 1174 1175 1176 - `#9823 <https://github.com/pytest-dev/pytest/issues/9823>`_: Improved error message that is shown when no collector is found for a given file. 1177 1178 1179 - `#9873 <https://github.com/pytest-dev/pytest/issues/9873>`_: Some coloring has been added to the short test summary. 1180 1181 1182 - `#9883 <https://github.com/pytest-dev/pytest/issues/9883>`_: Normalize the help description of all command-line options. 1183 1184 1185 - `#9920 <https://github.com/pytest-dev/pytest/issues/9920>`_: Display full crash messages in ``short test summary info``, when running in a CI environment. 1186 1187 1188 - `#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``. 1189 1190 1191 1192 Bug Fixes 1193 --------- 1194 1195 - `#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. 1196 1197 1198 - `#10382 <https://github.com/pytest-dev/pytest/issues/10382>`_: Do not break into pdb when ``raise unittest.SkipTest()`` appears top-level in a file. 1199 1200 1201 - `#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. 1202 1203 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. 1204 1205 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. 1206 1207 1208 - `#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``. 1209 1210 1211 - `#9877 <https://github.com/pytest-dev/pytest/issues/9877>`_: Ensure ``caplog.get_records(when)`` returns current/correct data after invoking ``caplog.clear()``. 1212 1213 1214 1215 Improved Documentation 1216 ---------------------- 1217 1218 - `#10344 <https://github.com/pytest-dev/pytest/issues/10344>`_: Update information on writing plugins to use ``pyproject.toml`` instead of ``setup.py``. 1219 1220 1221 - `#9248 <https://github.com/pytest-dev/pytest/issues/9248>`_: The documentation is now built using Sphinx 5.x (up from 3.x previously). 1222 1223 1224 - `#9291 <https://github.com/pytest-dev/pytest/issues/9291>`_: Update documentation on how :func:`pytest.warns` affects :class:`DeprecationWarning`. 1225 1226 1227 1228 Trivial/Internal Changes 1229 ------------------------ 1230 1231 - `#10313 <https://github.com/pytest-dev/pytest/issues/10313>`_: Made ``_pytest.doctest.DoctestItem`` export ``pytest.DoctestItem`` for 1232 type check and runtime purposes. Made `_pytest.doctest` use internal APIs 1233 to avoid circular imports. 1234 1235 1236 - `#9906 <https://github.com/pytest-dev/pytest/issues/9906>`_: Made ``_pytest.compat`` re-export ``importlib_metadata`` in the eyes of type checkers. 1237 1238 1239 - `#9910 <https://github.com/pytest-dev/pytest/issues/9910>`_: Fix default encoding warning (``EncodingWarning``) in ``cacheprovider`` 1240 1241 1242 - `#9984 <https://github.com/pytest-dev/pytest/issues/9984>`_: Improve the error message when we attempt to access a fixture that has been 1243 torn down. 1244 Add an additional sentence to the docstring explaining when it's not a good 1245 idea to call ``getfixturevalue``. 1246 1247 1248 pytest 7.1.3 (2022-08-31) 1249 ========================= 1250 1251 Bug Fixes 1252 --------- 1253 1254 - `#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``. 1255 1256 1257 - `#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. 1258 1259 1260 - `#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>`__. 1261 1262 1263 - `#3396 <https://github.com/pytest-dev/pytest/issues/3396>`_: Doctests now respect the ``--import-mode`` flag. 1264 1265 1266 - `#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. 1267 1268 1269 - `#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. 1270 1271 1272 - `#9917 <https://github.com/pytest-dev/pytest/issues/9917>`_: Fixed string representation for :func:`pytest.approx` when used to compare tuples. 1273 1274 1275 1276 Improved Documentation 1277 ---------------------- 1278 1279 - `#9937 <https://github.com/pytest-dev/pytest/issues/9937>`_: Explicit note that :fixture:`tmpdir` fixture is discouraged in favour of :fixture:`tmp_path`. 1280 1281 1282 1283 Trivial/Internal Changes 1284 ------------------------ 1285 1286 - `#10114 <https://github.com/pytest-dev/pytest/issues/10114>`_: Replace `atomicwrites <https://github.com/untitaker/python-atomicwrites>`__ dependency on windows with `os.replace`. 1287 1288 1289 pytest 7.1.2 (2022-04-23) 1290 ========================= 1291 1292 Bug Fixes 1293 --------- 1294 1295 - `#9726 <https://github.com/pytest-dev/pytest/issues/9726>`_: An unnecessary ``numpy`` import inside :func:`pytest.approx` was removed. 1296 1297 1298 - `#9820 <https://github.com/pytest-dev/pytest/issues/9820>`_: Fix comparison of ``dataclasses`` with ``InitVar``. 1299 1300 1301 - `#9869 <https://github.com/pytest-dev/pytest/issues/9869>`_: Increase ``stacklevel`` for the ``NODE_CTOR_FSPATH_ARG`` deprecation to point to the 1302 user's code, not pytest. 1303 1304 1305 - `#9871 <https://github.com/pytest-dev/pytest/issues/9871>`_: Fix a bizarre (and fortunately rare) bug where the `temp_path` fixture could raise 1306 an internal error while attempting to get the current user's username. 1307 1308 1309 pytest 7.1.1 (2022-03-17) 1310 ========================= 1311 1312 Bug Fixes 1313 --------- 1314 1315 - `#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. 1316 1317 1318 pytest 7.1.0 (2022-03-13) 1319 ========================= 1320 1321 Breaking Changes 1322 ---------------- 1323 1324 - `#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 1325 removed: 1326 1327 * ``pytest._fillfuncargs`` function. 1328 1329 * ``pytest_warning_captured`` hook - use ``pytest_warning_recorded`` instead. 1330 1331 * ``-k -foobar`` syntax - use ``-k 'not foobar'`` instead. 1332 1333 * ``-k foobar:`` syntax. 1334 1335 * ``pytest.collect`` module - import from ``pytest`` directly. 1336 1337 For more information consult 1338 `Deprecations and Removals <https://docs.pytest.org/en/latest/deprecations.html>`__ in the docs. 1339 1340 1341 - `#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. 1342 1343 1344 1345 Improvements 1346 ------------ 1347 1348 - `#5192 <https://github.com/pytest-dev/pytest/issues/5192>`_: Fixed test output for some data types where ``-v`` would show less information. 1349 1350 Also, when showing diffs for sequences, ``-q`` would produce full diffs instead of the expected diff. 1351 1352 1353 - `#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``. 1354 1355 1356 - `#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. 1357 1358 1359 - `#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 1360 be obtained by enabling :mod:`tracemalloc`. 1361 1362 See :ref:`resource-warnings` for more information. 1363 1364 1365 - `#9678 <https://github.com/pytest-dev/pytest/issues/9678>`_: More types are now accepted in the ``ids`` argument to ``@pytest.mark.parametrize``. 1366 Previously only `str`, `float`, `int` and `bool` were accepted; 1367 now `bytes`, `complex`, `re.Pattern`, `Enum` and anything with a `__name__` are also accepted. 1368 1369 1370 - `#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`). 1371 1372 Note that this implies that custom classes which only implement ``__iter__`` and ``__len__`` are no longer supported as they don't guarantee order. 1373 1374 1375 1376 Bug Fixes 1377 --------- 1378 1379 - `#8242 <https://github.com/pytest-dev/pytest/issues/8242>`_: The deprecation of raising :class:`unittest.SkipTest` to skip collection of 1380 tests during the pytest collection phase is reverted - this is now a supported 1381 feature again. 1382 1383 1384 - `#9493 <https://github.com/pytest-dev/pytest/issues/9493>`_: Symbolic link components are no longer resolved in conftest paths. 1385 This means that if a conftest appears twice in collection tree, using symlinks, it will be executed twice. 1386 For example, given 1387 1388 tests/real/conftest.py 1389 tests/real/test_it.py 1390 tests/link -> tests/real 1391 1392 running ``pytest tests`` now imports the conftest twice, once as ``tests/real/conftest.py`` and once as ``tests/link/conftest.py``. 1393 This is a fix to match a similar change made to test collection itself in pytest 6.0 (see :pull:`6523` for details). 1394 1395 1396 - `#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. 1397 1398 If there were errors or skipped modules on collection, pytest would mistakenly subtract those from the selected count. 1399 1400 1401 - `#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. 1402 1403 1404 - `#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. 1405 1406 1407 - `#9730 <https://github.com/pytest-dev/pytest/issues/9730>`_: Malformed ``pyproject.toml`` files now produce a clearer error message. 1408 1409 1410 pytest 7.0.1 (2022-02-11) 1411 ========================= 1412 1413 Bug Fixes 1414 --------- 1415 1416 - `#9608 <https://github.com/pytest-dev/pytest/issues/9608>`_: Fix invalid importing of ``importlib.readers`` in Python 3.9. 1417 1418 1419 - `#9610 <https://github.com/pytest-dev/pytest/issues/9610>`_: Restore `UnitTestFunction.obj` to return unbound rather than bound method. 1420 Fixes a crash during a failed teardown in unittest TestCases with non-default `__init__`. 1421 Regressed in pytest 7.0.0. 1422 1423 1424 - `#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. 1425 1426 1427 - `#9642 <https://github.com/pytest-dev/pytest/issues/9642>`_: Fix running tests by id with ``::`` in the parametrize portion. 1428 1429 1430 - `#9643 <https://github.com/pytest-dev/pytest/issues/9643>`_: Delay issuing a :class:`~pytest.PytestWarning` about diamond inheritance involving :class:`~pytest.Item` and 1431 :class:`~pytest.Collector` so it can be filtered using :ref:`standard warning filters <warnings>`. 1432 1433 1434 pytest 7.0.0 (2022-02-03) 1435 ========================= 1436 1437 (**Please see the full set of changes for this release also in the 7.0.0rc1 notes below**) 1438 1439 Deprecations 1440 ------------ 1441 1442 - `#9488 <https://github.com/pytest-dev/pytest/issues/9488>`_: If custom subclasses of nodes like :class:`pytest.Item` override the 1443 ``__init__`` method, they should take ``**kwargs``. See 1444 :ref:`uncooperative-constructors-deprecated` for details. 1445 1446 Note that a deprecation warning is only emitted when there is a conflict in the 1447 arguments pytest expected to pass. This deprecation was already part of pytest 1448 7.0.0rc1 but wasn't documented. 1449 1450 1451 1452 Bug Fixes 1453 --------- 1454 1455 - `#9355 <https://github.com/pytest-dev/pytest/issues/9355>`_: Fixed error message prints function decorators when using assert in Python 3.8 and above. 1456 1457 1458 - `#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``). 1459 1460 1461 1462 Improved Documentation 1463 ---------------------- 1464 1465 - `#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. 1466 1467 1468 - `#9505 <https://github.com/pytest-dev/pytest/issues/9505>`_: Clarify where the configuration files are located. To avoid confusions documentation mentions 1469 that configuration file is located in the root of the repository. 1470 1471 1472 1473 Trivial/Internal Changes 1474 ------------------------ 1475 1476 - `#9521 <https://github.com/pytest-dev/pytest/issues/9521>`_: Add test coverage to assertion rewrite path. 1477 1478 1479 pytest 7.0.0rc1 (2021-12-06) 1480 ============================ 1481 1482 Breaking Changes 1483 ---------------- 1484 1485 - `#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`. 1486 1487 Most plugins which refer to `reportinfo()` only define it as part of a custom :class:`pytest.Item` implementation. 1488 Since `py.path.local` is an `os.PathLike[str]`, these plugins are unaffected. 1489 1490 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)`. 1491 Although preferably, avoid the legacy `py.path.local` and use `pathlib.Path`, or use `item.location` or `item.path`, instead. 1492 1493 Note: pytest was not able to provide a deprecation period for this change. 1494 1495 1496 - `#8246 <https://github.com/pytest-dev/pytest/issues/8246>`_: ``--version`` now writes version information to ``stdout`` rather than ``stderr``. 1497 1498 1499 - `#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``. 1500 1501 The workaround was introduced in `#1281 <https://github.com/pytest-dev/pytest/pull/1281>`__ in 2015, however since then 1502 `pyreadline seems to have gone unmaintained <https://github.com/pyreadline/pyreadline/issues/58>`__, is `generating 1503 warnings <https://github.com/pytest-dev/pytest/issues/8847>`__, and will stop working on Python 3.10. 1504 1505 1506 - `#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. 1507 1508 It is apparently common for users to mistakenly use ``pytest.approx`` like this: 1509 1510 .. code-block:: python 1511 1512 assert pytest.approx(actual, expected) 1513 1514 While the correct usage is: 1515 1516 .. code-block:: python 1517 1518 assert actual == pytest.approx(expected) 1519 1520 The new error message helps catch those mistakes. 1521 1522 1523 - `#9277 <https://github.com/pytest-dev/pytest/issues/9277>`_: The ``pytest.Instance`` collector type has been removed. 1524 Importing ``pytest.Instance`` or ``_pytest.python.Instance`` returns a dummy type and emits a deprecation warning. 1525 See :ref:`instance-collector-deprecation` for details. 1526 1527 1528 - `#9308 <https://github.com/pytest-dev/pytest/issues/9308>`_: **PytestRemovedIn7Warning deprecation warnings are now errors by default.** 1529 1530 Following our plan to remove deprecated features with as little disruption as 1531 possible, all warnings of type ``PytestRemovedIn7Warning`` now generate errors 1532 instead of warning messages by default. 1533 1534 **The affected features will be effectively removed in pytest 7.1**, so please consult the 1535 :ref:`deprecations` section in the docs for directions on how to update existing code. 1536 1537 In the pytest ``7.0.X`` series, it is possible to change the errors back into warnings as a 1538 stopgap measure by adding this to your ``pytest.ini`` file: 1539 1540 .. code-block:: ini 1541 1542 [pytest] 1543 filterwarnings = 1544 ignore::pytest.PytestRemovedIn7Warning 1545 1546 But this will stop working when pytest ``7.1`` is released. 1547 1548 **If you have concerns** about the removal of a specific feature, please add a 1549 comment to :issue:`9308`. 1550 1551 1552 1553 Deprecations 1554 ------------ 1555 1556 - `#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. 1557 1558 ``py.path.local`` arguments to Node constructors have been deprecated. See :ref:`the deprecation note <node-ctor-fspath-deprecation>` for full details. 1559 1560 .. note:: 1561 The name of the :class:`~_pytest.nodes.Node` arguments and attributes (the 1562 new attribute being ``path``) is **the opposite** of the situation for hooks 1563 (the old argument being ``path``). 1564 1565 This is an unfortunate artifact due to historical reasons, which should be 1566 resolved in future versions as we slowly get rid of the :pypi:`py` 1567 dependency (see :issue:`9283` for a longer discussion). 1568 1569 1570 - `#7469 <https://github.com/pytest-dev/pytest/issues/7469>`_: Directly constructing the following classes is now deprecated: 1571 1572 - ``_pytest.mark.structures.Mark`` 1573 - ``_pytest.mark.structures.MarkDecorator`` 1574 - ``_pytest.mark.structures.MarkGenerator`` 1575 - ``_pytest.python.Metafunc`` 1576 - ``_pytest.runner.CallInfo`` 1577 - ``_pytest._code.ExceptionInfo`` 1578 - ``_pytest.config.argparsing.Parser`` 1579 - ``_pytest.config.argparsing.OptionGroup`` 1580 - ``_pytest.pytester.HookRecorder`` 1581 1582 These constructors have always been considered private, but now issue a deprecation warning, which may become a hard error in pytest 8. 1583 1584 1585 - `#8242 <https://github.com/pytest-dev/pytest/issues/8242>`_: Raising :class:`unittest.SkipTest` to skip collection of tests during the 1586 pytest collection phase is deprecated. Use :func:`pytest.skip` instead. 1587 1588 Note: This deprecation only relates to using :class:`unittest.SkipTest` during test 1589 collection. You are probably not doing that. Ordinary usage of 1590 :class:`unittest.SkipTest` / :meth:`unittest.TestCase.skipTest` / 1591 :func:`unittest.skip` in unittest test cases is fully supported. 1592 1593 .. note:: This deprecation has been reverted in pytest 7.1.0. 1594 1595 1596 - `#8315 <https://github.com/pytest-dev/pytest/issues/8315>`_: Several behaviors of :meth:`Parser.addoption <pytest.Parser.addoption>` are now 1597 scheduled for removal in pytest 8 (deprecated since pytest 2.4.0): 1598 1599 - ``parser.addoption(..., help=".. %default ..")`` - use ``%(default)s`` instead. 1600 - ``parser.addoption(..., type="int/string/float/complex")`` - use ``type=int`` etc. instead. 1601 1602 1603 - `#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. 1604 It was never sanely supported and triggers hard to debug errors. 1605 1606 See :ref:`the deprecation note <diamond-inheritance-deprecated>` for full details. 1607 1608 1609 - `#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. 1610 1611 See :ref:`the deprecation note <cmdline-preparse-deprecated>` for full details. 1612 1613 1614 - `#8645 <https://github.com/pytest-dev/pytest/issues/8645>`_: :func:`pytest.warns(None) <pytest.warns>` is now deprecated because many people used 1615 it to mean "this code does not emit warnings", but it actually had the effect of 1616 checking that the code emits at least one warning of any type - like ``pytest.warns()`` 1617 or ``pytest.warns(Warning)``. 1618 1619 1620 - `#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>` 1621 signatures now accept a ``reason`` argument instead of ``msg``. Using ``msg`` still works, but is deprecated and will be removed in a future release. 1622 1623 This was changed for consistency with :func:`pytest.mark.skip <pytest.mark.skip>` and :func:`pytest.mark.xfail <pytest.mark.xfail>` which both accept 1624 ``reason`` as an argument. 1625 1626 - `#8174 <https://github.com/pytest-dev/pytest/issues/8174>`_: The following changes have been made to types reachable through :attr:`pytest.ExceptionInfo.traceback`: 1627 1628 - The ``path`` property of ``_pytest.code.Code`` returns ``Path`` instead of ``py.path.local``. 1629 - The ``path`` property of ``_pytest.code.TracebackEntry`` returns ``Path`` instead of ``py.path.local``. 1630 1631 There was no deprecation period for this change (sorry!). 1632 1633 1634 Features 1635 -------- 1636 1637 - `#5196 <https://github.com/pytest-dev/pytest/issues/5196>`_: Tests are now ordered by definition order in more cases. 1638 1639 In a class hierarchy, tests from base classes are now consistently ordered before tests defined on their subclasses (reverse MRO order). 1640 1641 1642 - `#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. 1643 1644 1645 - `#7259 <https://github.com/pytest-dev/pytest/issues/7259>`_: Added :meth:`cache.mkdir() <pytest.Cache.mkdir>`, which is similar to the existing ``cache.makedir()``, 1646 but returns a :class:`pathlib.Path` instead of a legacy ``py.path.local``. 1647 1648 Added a ``paths`` type to :meth:`parser.addini() <pytest.Parser.addini>`, 1649 as in ``parser.addini("mypaths", "my paths", type="paths")``, 1650 which is similar to the existing ``pathlist``, 1651 but returns a list of :class:`pathlib.Path` instead of legacy ``py.path.local``. 1652 1653 1654 - `#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. 1655 1656 The newly-exported types are: 1657 1658 - ``pytest.Config`` for :class:`Config <pytest.Config>`. 1659 - ``pytest.Mark`` for :class:`marks <pytest.Mark>`. 1660 - ``pytest.MarkDecorator`` for :class:`mark decorators <pytest.MarkDecorator>`. 1661 - ``pytest.MarkGenerator`` for the :class:`pytest.mark <pytest.MarkGenerator>` singleton. 1662 - ``pytest.Metafunc`` for the :class:`metafunc <pytest.MarkGenerator>` argument to the :hook:`pytest_generate_tests` hook. 1663 - ``pytest.CallInfo`` for the :class:`CallInfo <pytest.CallInfo>` type passed to various hooks. 1664 - ``pytest.PytestPluginManager`` for :class:`PytestPluginManager <pytest.PytestPluginManager>`. 1665 - ``pytest.ExceptionInfo`` for the :class:`ExceptionInfo <pytest.ExceptionInfo>` type returned from :func:`pytest.raises` and passed to various hooks. 1666 - ``pytest.Parser`` for the :class:`Parser <pytest.Parser>` type passed to the :hook:`pytest_addoption` hook. 1667 - ``pytest.OptionGroup`` for the :class:`OptionGroup <pytest.OptionGroup>` type returned from the :func:`parser.addgroup <pytest.Parser.getgroup>` method. 1668 - ``pytest.HookRecorder`` for the :class:`HookRecorder <pytest.HookRecorder>` type returned from :class:`~pytest.Pytester`. 1669 - ``pytest.RecordedHookCall`` for the :class:`RecordedHookCall <pytest.HookRecorder>` type returned from :class:`~pytest.HookRecorder`. 1670 - ``pytest.RunResult`` for the :class:`RunResult <pytest.RunResult>` type returned from :class:`~pytest.Pytester`. 1671 - ``pytest.LineMatcher`` for the :class:`LineMatcher <pytest.LineMatcher>` type used in :class:`~pytest.RunResult` and others. 1672 - ``pytest.TestReport`` for the :class:`TestReport <pytest.TestReport>` type used in various hooks. 1673 - ``pytest.CollectReport`` for the :class:`CollectReport <pytest.CollectReport>` type used in various hooks. 1674 1675 Constructing most of them directly is not supported; they are only meant for use in type annotations. 1676 Doing so will emit a deprecation warning, and may become a hard-error in pytest 8.0. 1677 1678 Subclassing them is also not supported. This is not currently enforced at runtime, but is detected by type-checkers such as mypy. 1679 1680 1681 - `#7856 <https://github.com/pytest-dev/pytest/issues/7856>`_: :ref:`--import-mode=importlib <import-modes>` now works with features that 1682 depend on modules being on :py:data:`sys.modules`, such as :mod:`pickle` and :mod:`dataclasses`. 1683 1684 1685 - `#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: 1686 1687 - :hook:`pytest_ignore_collect` - The ``collection_path`` parameter (equivalent to existing ``path`` parameter). 1688 - :hook:`pytest_collect_file` - The ``file_path`` parameter (equivalent to existing ``path`` parameter). 1689 - :hook:`pytest_pycollect_makemodule` - The ``module_path`` parameter (equivalent to existing ``path`` parameter). 1690 - :hook:`pytest_report_header` - The ``start_path`` parameter (equivalent to existing ``startdir`` parameter). 1691 - :hook:`pytest_report_collectionfinish` - The ``start_path`` parameter (equivalent to existing ``startdir`` parameter). 1692 1693 .. note:: 1694 The name of the :class:`~_pytest.nodes.Node` arguments and attributes (the 1695 new attribute being ``path``) is **the opposite** of the situation for hooks 1696 (the old argument being ``path``). 1697 1698 This is an unfortunate artifact due to historical reasons, which should be 1699 resolved in future versions as we slowly get rid of the :pypi:`py` 1700 dependency (see :issue:`9283` for a longer discussion). 1701 1702 1703 - `#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 1704 due to the ongoing migration of methods like :meth:`~pytest.Item.reportinfo`, we expect to deprecate it in a future release. 1705 1706 .. note:: 1707 The name of the :class:`~_pytest.nodes.Node` arguments and attributes (the 1708 new attribute being ``path``) is **the opposite** of the situation for hooks 1709 (the old argument being ``path``). 1710 1711 This is an unfortunate artifact due to historical reasons, which should be 1712 resolved in future versions as we slowly get rid of the :pypi:`py` 1713 dependency (see :issue:`9283` for a longer discussion). 1714 1715 1716 - `#8421 <https://github.com/pytest-dev/pytest/issues/8421>`_: :func:`pytest.approx` now works on :class:`~decimal.Decimal` within mappings/dicts and sequences/lists. 1717 1718 1719 - `#8606 <https://github.com/pytest-dev/pytest/issues/8606>`_: pytest invocations with ``--fixtures-per-test`` and ``--fixtures`` have been enriched with: 1720 1721 - Fixture location path printed with the fixture name. 1722 - First section of the fixture's docstring printed under the fixture name. 1723 - Whole of fixture's docstring printed under the fixture name using ``--verbose`` option. 1724 1725 1726 - `#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). 1727 1728 1729 - `#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``. 1730 1731 1732 - `#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. 1733 See :ref:`plugin-stash` for details. 1734 1735 1736 - `#8953 <https://github.com/pytest-dev/pytest/issues/8953>`_: :class:`~pytest.RunResult` method :meth:`~pytest.RunResult.assert_outcomes` now accepts a 1737 ``warnings`` argument to assert the total number of warnings captured. 1738 1739 1740 - `#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`. 1741 1742 1743 - `#9023 <https://github.com/pytest-dev/pytest/issues/9023>`_: Full diffs are now always shown for equality assertions of iterables when 1744 `CI` or ``BUILD_NUMBER`` is found in the environment, even when ``-v`` isn't 1745 used. 1746 1747 1748 - `#9113 <https://github.com/pytest-dev/pytest/issues/9113>`_: :class:`~pytest.RunResult` method :meth:`~pytest.RunResult.assert_outcomes` now accepts a 1749 ``deselected`` argument to assert the total number of deselected tests. 1750 1751 1752 - `#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. 1753 1754 1755 1756 Improvements 1757 ------------ 1758 1759 - `#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`, 1760 a subclass of :class:`~pytest.PytestDeprecationWarning`, 1761 instead of :class:`~pytest.PytestDeprecationWarning` directly. 1762 1763 See :ref:`backwards-compatibility` for more details. 1764 1765 1766 - `#7864 <https://github.com/pytest-dev/pytest/issues/7864>`_: Improved error messages when parsing warning filters. 1767 1768 Previously pytest would show an internal traceback, which besides being ugly sometimes would hide the cause 1769 of the problem (for example an ``ImportError`` while importing a specific warning type). 1770 1771 1772 - `#8335 <https://github.com/pytest-dev/pytest/issues/8335>`_: Improved :func:`pytest.approx` assertion messages for sequences of numbers. 1773 1774 The assertion messages now dumps a table with the index and the error of each diff. 1775 Example:: 1776 1777 > assert [1, 2, 3, 4] == pytest.approx([1, 3, 3, 5]) 1778 E assert comparison failed for 2 values: 1779 E Index | Obtained | Expected 1780 E 1 | 2 | 3 +- 3.0e-06 1781 E 3 | 4 | 5 +- 5.0e-06 1782 1783 1784 - `#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, 1785 currently at ``240`` characters by default. 1786 1787 However, in some cases the longer output helps, or is even crucial, to diagnose a failure. Using ``-v`` will 1788 now increase the truncation threshold to ``2400`` characters, and ``-vv`` or higher will disable truncation entirely. 1789 1790 1791 - `#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. 1792 1793 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``. 1794 1795 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. 1796 1797 1798 - `#8803 <https://github.com/pytest-dev/pytest/issues/8803>`_: It is now possible to add colors to custom log levels on cli log. 1799 1800 By using ``add_color_level`` from a :hook:`pytest_configure` hook, colors can be added:: 1801 1802 logging_plugin = config.pluginmanager.get_plugin('logging-plugin') 1803 logging_plugin.log_cli_handler.formatter.add_color_level(logging.INFO, 'cyan') 1804 logging_plugin.log_cli_handler.formatter.add_color_level(logging.SPAM, 'blue') 1805 1806 See :ref:`log_colors` for more information. 1807 1808 1809 - `#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. 1810 1811 1812 - `#8898 <https://github.com/pytest-dev/pytest/issues/8898>`_: Complex numbers are now treated like floats and integers when generating parameterization IDs. 1813 1814 1815 - `#9062 <https://github.com/pytest-dev/pytest/issues/9062>`_: ``--stepwise-skip`` now implicitly enables ``--stepwise`` and can be used on its own. 1816 1817 1818 - `#9205 <https://github.com/pytest-dev/pytest/issues/9205>`_: :meth:`pytest.Cache.set` now preserves key order when saving dicts. 1819 1820 1821 1822 Bug Fixes 1823 --------- 1824 1825 - `#7124 <https://github.com/pytest-dev/pytest/issues/7124>`_: Fixed an issue where ``__main__.py`` would raise an ``ImportError`` when ``--doctest-modules`` was provided. 1826 1827 1828 - `#8061 <https://github.com/pytest-dev/pytest/issues/8061>`_: Fixed failing ``staticmethod`` test cases if they are inherited from a parent test class. 1829 1830 1831 - `#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. 1832 1833 ``pytester.makefile`` now issues a clearer error if the ``.`` is missing in the ``ext`` argument. 1834 1835 1836 - `#8258 <https://github.com/pytest-dev/pytest/issues/8258>`_: Fixed issue where pytest's ``faulthandler`` support would not dump traceback on crashes 1837 if the :mod:`faulthandler` module was already enabled during pytest startup (using 1838 ``python -X dev -m pytest`` for example). 1839 1840 1841 - `#8317 <https://github.com/pytest-dev/pytest/issues/8317>`_: Fixed an issue where illegal directory characters derived from ``getpass.getuser()`` raised an ``OSError``. 1842 1843 1844 - `#8367 <https://github.com/pytest-dev/pytest/issues/8367>`_: Fix ``Class.from_parent`` so it forwards extra keyword arguments to the constructor. 1845 1846 1847 - `#8377 <https://github.com/pytest-dev/pytest/issues/8377>`_: The test selection options ``pytest -k`` and ``pytest -m`` now support matching 1848 names containing forward slash (``/``) characters. 1849 1850 1851 - `#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). 1852 1853 1854 - `#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``). 1855 1856 1857 - `#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. 1858 1859 1860 - `#8464 <https://github.com/pytest-dev/pytest/issues/8464>`_: ``-c <config file>`` now also properly defines ``rootdir`` as the directory that contains ``<config file>``. 1861 1862 1863 - `#8503 <https://github.com/pytest-dev/pytest/issues/8503>`_: :meth:`pytest.MonkeyPatch.syspath_prepend` no longer fails when 1864 ``setuptools`` is not installed. 1865 It now only calls ``pkg_resources.fixup_namespace_packages`` if 1866 ``pkg_resources`` was previously imported, because it is not needed otherwise. 1867 1868 1869 - `#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. 1870 1871 1872 - `#8796 <https://github.com/pytest-dev/pytest/issues/8796>`_: Fixed internal error when skipping doctests. 1873 1874 1875 - `#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. 1876 Backslashes are treated literally, not as escape characters (the values being matched against are already escaped). 1877 1878 1879 - `#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. 1880 1881 1882 - `#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. 1883 1884 1885 - `#9131 <https://github.com/pytest-dev/pytest/issues/9131>`_: Fixed the URL used by ``--pastebin`` to use `bpa.st <http://bpa.st>`__. 1886 1887 1888 - `#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. 1889 1890 1891 - `#9169 <https://github.com/pytest-dev/pytest/issues/9169>`_: Support for the ``files`` API from ``importlib.resources`` within rewritten files. 1892 1893 1894 - `#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. 1895 They are now called even if object-level `setup`/`teardown` is defined. 1896 1897 1898 1899 Improved Documentation 1900 ---------------------- 1901 1902 - `#4320 <https://github.com/pytest-dev/pytest/issues/4320>`_: Improved docs for `pytester.copy_example`. 1903 1904 1905 - `#5105 <https://github.com/pytest-dev/pytest/issues/5105>`_: Add automatically generated :ref:`plugin-list`. The list is updated on a periodic schedule. 1906 1907 1908 - `#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. 1909 1910 1911 - `#8655 <https://github.com/pytest-dev/pytest/issues/8655>`_: Help text for ``--pdbcls`` more accurately reflects the option's behavior. 1912 1913 1914 - `#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. 1915 1916 1917 - `#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. 1918 1919 1920 - `#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. 1921 1922 1923 1924 Trivial/Internal Changes 1925 ------------------------ 1926 1927 - `#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. 1928 1929 1930 - `#8174 <https://github.com/pytest-dev/pytest/issues/8174>`_: The following changes have been made to internal pytest types/functions: 1931 1932 - The ``_pytest.code.getfslineno()`` function returns ``Path`` instead of ``py.path.local``. 1933 - The ``_pytest.python.path_matches_patterns()`` function takes ``Path`` instead of ``py.path.local``. 1934 - The ``_pytest._code.Traceback.cut()`` function accepts any ``os.PathLike[str]``, not just ``py.path.local``. 1935 1936 1937 - `#8248 <https://github.com/pytest-dev/pytest/issues/8248>`_: Internal Restructure: let ``python.PyObjMixin`` inherit from ``nodes.Node`` to carry over typing information. 1938 1939 1940 - `#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`. 1941 1942 1943 - `#8818 <https://github.com/pytest-dev/pytest/issues/8818>`_: Ensure ``regendoc`` opts out of ``TOX_ENV`` cachedir selection to ensure independent example test runs. 1944 1945 1946 - `#8913 <https://github.com/pytest-dev/pytest/issues/8913>`_: The private ``CallSpec2._arg2scopenum`` attribute has been removed after an internal refactoring. 1947 1948 1949 - `#8967 <https://github.com/pytest-dev/pytest/issues/8967>`_: :hook:`pytest_assertion_pass` is no longer considered experimental and 1950 future changes to it will be considered more carefully. 1951 1952 1953 - `#9202 <https://github.com/pytest-dev/pytest/issues/9202>`_: Add github action to upload coverage report to codecov instead of bash uploader. 1954 1955 1956 - `#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. 1957 1958 1959 - `#9351 <https://github.com/pytest-dev/pytest/issues/9351>`_: Correct minor typos in doc/en/example/special.rst. 1960 1961 1962 pytest 6.2.5 (2021-08-29) 1963 ========================= 1964 1965 1966 Trivial/Internal Changes 1967 ------------------------ 1968 1969 - :issue:`8494`: Python 3.10 is now supported. 1970 1971 1972 - :issue:`9040`: Enable compatibility with ``pluggy 1.0`` or later. 1973 1974 1975 pytest 6.2.4 (2021-05-04) 1976 ========================= 1977 1978 Bug Fixes 1979 --------- 1980 1981 - :issue:`8539`: Fixed assertion rewriting on Python 3.10. 1982 1983 1984 pytest 6.2.3 (2021-04-03) 1985 ========================= 1986 1987 Bug Fixes 1988 --------- 1989 1990 - :issue:`8414`: pytest used to create directories under ``/tmp`` with world-readable 1991 permissions. This means that any user in the system was able to read 1992 information written by tests in temporary directories (such as those created by 1993 the ``tmp_path``/``tmpdir`` fixture). Now the directories are created with 1994 private permissions. 1995 1996 pytest used to silently use a preexisting ``/tmp/pytest-of-<username>`` directory, 1997 even if owned by another user. This means another user could pre-create such a 1998 directory and gain control of another user's temporary directory. Now such a 1999 condition results in an error. 2000 2001 2002 pytest 6.2.2 (2021-01-25) 2003 ========================= 2004 2005 Bug Fixes 2006 --------- 2007 2008 - :issue:`8152`: Fixed "(<Skipped instance>)" being shown as a skip reason in the verbose test summary line when the reason is empty. 2009 2010 2011 - :issue:`8249`: Fix the ``faulthandler`` plugin for occasions when running with ``twisted.logger`` and using ``pytest --capture=no``. 2012 2013 2014 pytest 6.2.1 (2020-12-15) 2015 ========================= 2016 2017 Bug Fixes 2018 --------- 2019 2020 - :issue:`7678`: Fixed bug where ``ImportPathMismatchError`` would be raised for files compiled in 2021 the host and loaded later from an UNC mounted path (Windows). 2022 2023 2024 - :issue:`8132`: Fixed regression in ``approx``: in 6.2.0 ``approx`` no longer raises 2025 ``TypeError`` when dealing with non-numeric types, falling back to normal comparison. 2026 Before 6.2.0, array types like tf.DeviceArray fell through to the scalar case, 2027 and happened to compare correctly to a scalar if they had only one element. 2028 After 6.2.0, these types began failing, because they inherited neither from 2029 standard Python number hierarchy nor from ``numpy.ndarray``. 2030 2031 ``approx`` now converts arguments to ``numpy.ndarray`` if they expose the array 2032 protocol and are not scalars. This treats array-like objects like numpy arrays, 2033 regardless of size. 2034 2035 2036 pytest 6.2.0 (2020-12-12) 2037 ========================= 2038 2039 Breaking Changes 2040 ---------------- 2041 2042 - :issue:`7808`: pytest now supports python3.6+ only. 2043 2044 2045 2046 Deprecations 2047 ------------ 2048 2049 - :issue:`7469`: Directly constructing/calling the following classes/functions is now deprecated: 2050 2051 - ``_pytest.cacheprovider.Cache`` 2052 - ``_pytest.cacheprovider.Cache.for_config()`` 2053 - ``_pytest.cacheprovider.Cache.clear_cache()`` 2054 - ``_pytest.cacheprovider.Cache.cache_dir_from_config()`` 2055 - ``_pytest.capture.CaptureFixture`` 2056 - ``_pytest.fixtures.FixtureRequest`` 2057 - ``_pytest.fixtures.SubRequest`` 2058 - ``_pytest.logging.LogCaptureFixture`` 2059 - ``_pytest.pytester.Pytester`` 2060 - ``_pytest.pytester.Testdir`` 2061 - ``_pytest.recwarn.WarningsRecorder`` 2062 - ``_pytest.recwarn.WarningsChecker`` 2063 - ``_pytest.tmpdir.TempPathFactory`` 2064 - ``_pytest.tmpdir.TempdirFactory`` 2065 2066 These have always been considered private, but now issue a deprecation warning, which may become a hard error in pytest 8.0.0. 2067 2068 2069 - :issue:`7530`: The ``--strict`` command-line option has been deprecated, use ``--strict-markers`` instead. 2070 2071 We have plans to maybe in the future to reintroduce ``--strict`` and make it an encompassing flag for all strictness 2072 related options (``--strict-markers`` and ``--strict-config`` at the moment, more might be introduced in the future). 2073 2074 2075 - :issue:`7988`: The ``@pytest.yield_fixture`` decorator/function is now deprecated. Use :func:`pytest.fixture` instead. 2076 2077 ``yield_fixture`` has been an alias for ``fixture`` for a very long time, so can be search/replaced safely. 2078 2079 2080 2081 Features 2082 -------- 2083 2084 - :issue:`5299`: pytest now warns about unraisable exceptions and unhandled thread exceptions that occur in tests on Python>=3.8. 2085 See :ref:`unraisable` for more information. 2086 2087 2088 - :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``. 2089 2090 This is part of the movement to use :class:`pathlib.Path` objects internally, in order to remove the dependency to ``py`` in the future. 2091 2092 Internally, the old ``pytest.Testdir`` is now a thin wrapper around :class:`~pytest.Pytester`, preserving the old interface. 2093 2094 2095 - :issue:`7695`: A new hook was added, `pytest_markeval_namespace` which should return a dictionary. 2096 This dictionary will be used to augment the "global" variables available to evaluate skipif/xfail/xpass markers. 2097 2098 Pseudo example 2099 2100 ``conftest.py``: 2101 2102 .. code-block:: python 2103 2104 def pytest_markeval_namespace(): 2105 return {"color": "red"} 2106 2107 ``test_func.py``: 2108 2109 .. code-block:: python 2110 2111 @pytest.mark.skipif("color == 'blue'", reason="Color is not red") 2112 def test_func(): 2113 assert False 2114 2115 2116 - :issue:`8006`: It is now possible to construct a :class:`~pytest.MonkeyPatch` object directly as ``pytest.MonkeyPatch()``, 2117 in cases when the :fixture:`monkeypatch` fixture cannot be used. Previously some users imported it 2118 from the private `_pytest.monkeypatch.MonkeyPatch` namespace. 2119 2120 Additionally, :meth:`MonkeyPatch.context <pytest.MonkeyPatch.context>` is now a classmethod, 2121 and can be used as ``with MonkeyPatch.context() as mp: ...``. This is the recommended way to use 2122 ``MonkeyPatch`` directly, since unlike the ``monkeypatch`` fixture, an instance created directly 2123 is not ``undo()``-ed automatically. 2124 2125 2126 2127 Improvements 2128 ------------ 2129 2130 - :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. 2131 2132 2133 - :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". 2134 2135 2136 - :issue:`7469` The types of builtin pytest fixtures are now exported so they may be used in type annotations of test functions. 2137 The newly-exported types are: 2138 2139 - ``pytest.FixtureRequest`` for the :fixture:`request` fixture. 2140 - ``pytest.Cache`` for the :fixture:`cache` fixture. 2141 - ``pytest.CaptureFixture[str]`` for the :fixture:`capfd` and :fixture:`capsys` fixtures. 2142 - ``pytest.CaptureFixture[bytes]`` for the :fixture:`capfdbinary` and :fixture:`capsysbinary` fixtures. 2143 - ``pytest.LogCaptureFixture`` for the :fixture:`caplog` fixture. 2144 - ``pytest.Pytester`` for the :fixture:`pytester` fixture. 2145 - ``pytest.Testdir`` for the :fixture:`testdir` fixture. 2146 - ``pytest.TempdirFactory`` for the :fixture:`tmpdir_factory` fixture. 2147 - ``pytest.TempPathFactory`` for the :fixture:`tmp_path_factory` fixture. 2148 - ``pytest.MonkeyPatch`` for the :fixture:`monkeypatch` fixture. 2149 - ``pytest.WarningsRecorder`` for the :fixture:`recwarn` fixture. 2150 2151 Constructing them is not supported (except for `MonkeyPatch`); they are only meant for use in type annotations. 2152 Doing so will emit a deprecation warning, and may become a hard-error in pytest 8.0. 2153 2154 Subclassing them is also not supported. This is not currently enforced at runtime, but is detected by type-checkers such as mypy. 2155 2156 2157 - :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. 2158 2159 2160 - :issue:`7615`: :meth:`Node.warn <_pytest.nodes.Node.warn>` now permits any subclass of :class:`Warning`, not just :class:`PytestWarning <pytest.PytestWarning>`. 2161 2162 2163 - :issue:`7701`: Improved reporting when using ``--collected-only``. It will now show the number of collected tests in the summary stats. 2164 2165 2166 - :issue:`7710`: Use strict equality comparison for non-numeric types in :func:`pytest.approx` instead of 2167 raising :class:`TypeError`. 2168 2169 This was the undocumented behavior before 3.7, but is now officially a supported feature. 2170 2171 2172 - :issue:`7938`: New ``--sw-skip`` argument which is a shorthand for ``--stepwise-skip``. 2173 2174 2175 - :issue:`8023`: Added ``'node_modules'`` to default value for :confval:`norecursedirs`. 2176 2177 2178 - :issue:`8032`: :meth:`doClassCleanups <unittest.TestCase.doClassCleanups>` (introduced in :mod:`unittest` in Python and 3.8) is now called appropriately. 2179 2180 2181 2182 Bug Fixes 2183 --------- 2184 2185 - :issue:`4824`: Fixed quadratic behavior and improved performance of collection of items using autouse fixtures and xunit fixtures. 2186 2187 2188 - :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. 2189 2190 2191 - :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. 2192 2193 2194 - :issue:`7913`: Fixed a crash or hang in :meth:`pytester.spawn <pytest.Pytester.spawn>` when the :mod:`readline` module is involved. 2195 2196 2197 - :issue:`7951`: Fixed handling of recursive symlinks when collecting tests. 2198 2199 2200 - :issue:`7981`: Fixed symlinked directories not being followed during collection. Regressed in pytest 6.1.0. 2201 2202 2203 - :issue:`8016`: Fixed only one doctest being collected when using ``pytest --doctest-modules path/to/an/__init__.py``. 2204 2205 2206 2207 Improved Documentation 2208 ---------------------- 2209 2210 - :issue:`7429`: Add more information and use cases about skipping doctests. 2211 2212 2213 - :issue:`7780`: Classes which should not be inherited from are now marked ``final class`` in the API reference. 2214 2215 2216 - :issue:`7872`: ``_pytest.config.argparsing.Parser.addini()`` accepts explicit ``None`` and ``"string"``. 2217 2218 2219 - :issue:`7878`: In pull request section, ask to commit after editing changelog and authors file. 2220 2221 2222 2223 Trivial/Internal Changes 2224 ------------------------ 2225 2226 - :issue:`7802`: The ``attrs`` dependency requirement is now >=19.2.0 instead of >=17.4.0. 2227 2228 2229 - :issue:`8014`: `.pyc` files created by pytest's assertion rewriting now conform to the newer :pep:`552` format on Python>=3.7. 2230 (These files are internal and only interpreted by pytest itself.) 2231 2232 2233 pytest 6.1.2 (2020-10-28) 2234 ========================= 2235 2236 Bug Fixes 2237 --------- 2238 2239 - :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. 2240 2241 2242 - :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. 2243 2244 2245 2246 Improved Documentation 2247 ---------------------- 2248 2249 - :issue:`7815`: Improve deprecation warning message for ``pytest._fillfuncargs()``. 2250 2251 2252 pytest 6.1.1 (2020-10-03) 2253 ========================= 2254 2255 Bug Fixes 2256 --------- 2257 2258 - :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. 2259 2260 2261 - :issue:`7814`: Fixed crash in header reporting when :confval:`testpaths` is used and contains absolute paths (regression in 6.1.0). 2262 2263 2264 pytest 6.1.0 (2020-09-26) 2265 ========================= 2266 2267 Breaking Changes 2268 ---------------- 2269 2270 - :issue:`5585`: As per our policy, the following features which have been deprecated in the 5.X series are now 2271 removed: 2272 2273 * The ``funcargnames`` read-only property of ``FixtureRequest``, ``Metafunc``, and ``Function`` classes. Use ``fixturenames`` attribute. 2274 2275 * ``@pytest.fixture`` no longer supports positional arguments, pass all arguments by keyword instead. 2276 2277 * Direct construction of ``Node`` subclasses now raise an error, use ``from_parent`` instead. 2278 2279 * The default value for ``junit_family`` has changed to ``xunit2``. If you require the old format, add ``junit_family=xunit1`` to your configuration file. 2280 2281 * 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. 2282 2283 * The ``--result-log`` option has been removed. Users are recommended to use the `pytest-reportlog <https://github.com/pytest-dev/pytest-reportlog>`__ plugin instead. 2284 2285 2286 For more information consult :std:doc:`deprecations` in the docs. 2287 2288 2289 2290 Deprecations 2291 ------------ 2292 2293 - :issue:`6981`: The ``pytest.collect`` module is deprecated: all its names can be imported from ``pytest`` directly. 2294 2295 2296 - :issue:`7097`: The ``pytest._fillfuncargs`` function is deprecated. This function was kept 2297 for backward compatibility with an older plugin. 2298 2299 It's functionality is not meant to be used directly, but if you must replace 2300 it, use `function._request._fillfixtures()` instead, though note this is not 2301 a public API and may break in the future. 2302 2303 2304 - :issue:`7210`: The special ``-k '-expr'`` syntax to ``-k`` is deprecated. Use ``-k 'not expr'`` 2305 instead. 2306 2307 The special ``-k 'expr:'`` syntax to ``-k`` is deprecated. Please open an issue 2308 if you use this and want a replacement. 2309 2310 2311 - :issue:`7255`: The ``pytest_warning_captured`` hook is deprecated in favor 2312 of :hook:`pytest_warning_recorded`, and will be removed in a future version. 2313 2314 2315 - :issue:`7648`: The ``gethookproxy()`` and ``isinitpath()`` methods of ``FSCollector`` and ``Package`` are deprecated; 2316 use ``self.session.gethookproxy()`` and ``self.session.isinitpath()`` instead. 2317 This should work on all pytest versions. 2318 2319 2320 2321 Features 2322 -------- 2323 2324 - :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``. 2325 2326 2327 2328 Improvements 2329 ------------ 2330 2331 - :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``. 2332 2333 This also fixes a number of long standing issues: :issue:`2891`, :issue:`7620`, :issue:`7426`. 2334 2335 2336 - :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. 2337 2338 2339 - :issue:`7685`: Added two new attributes :attr:`rootpath <pytest.Config.rootpath>` and :attr:`inipath <pytest.Config.inipath>` to :class:`~pytest.Config`. 2340 These attributes are :class:`pathlib.Path` versions of the existing ``rootdir`` and ``inifile`` attributes, 2341 and should be preferred over them when possible. 2342 2343 2344 - :issue:`7780`: Public classes which are not designed to be inherited from are now marked :func:`@final <typing.final>`. 2345 Code which inherits from these classes will trigger a type-checking (e.g. mypy) error, but will still work in runtime. 2346 Currently the ``final`` designation does not appear in the API Reference but hopefully will in the future. 2347 2348 2349 2350 Bug Fixes 2351 --------- 2352 2353 - :issue:`1953`: Fixed error when overwriting a parametrized fixture, while also reusing the super fixture value. 2354 2355 .. code-block:: python 2356 2357 # conftest.py 2358 import pytest 2359 2360 2361 @pytest.fixture(params=[1, 2]) 2362 def foo(request): 2363 return request.param 2364 2365 2366 # test_foo.py 2367 import pytest 2368 2369 2370 @pytest.fixture 2371 def foo(foo): 2372 return foo * 2 2373 2374 2375 - :issue:`4984`: Fixed an internal error crash with ``IndexError: list index out of range`` when 2376 collecting a module which starts with a decorated function, the decorator 2377 raises, and assertion rewriting is enabled. 2378 2379 2380 - :issue:`7591`: pylint shouldn't complain anymore about unimplemented abstract methods when inheriting from :ref:`File <non-python tests>`. 2381 2382 2383 - :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``). 2384 2385 2386 - :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``. 2387 2388 2389 - :issue:`7742`: Fixed INTERNALERROR when accessing locals / globals with faulty ``exec``. 2390 2391 2392 2393 Improved Documentation 2394 ---------------------- 2395 2396 - :issue:`1477`: Removed faq.rst and its reference in contents.rst. 2397 2398 2399 2400 Trivial/Internal Changes 2401 ------------------------ 2402 2403 - :issue:`7536`: The internal ``junitxml`` plugin has rewritten to use ``xml.etree.ElementTree``. 2404 The order of attributes in XML elements might differ. Some unneeded escaping is 2405 no longer performed. 2406 2407 2408 - :issue:`7587`: The dependency on the ``more-itertools`` package has been removed. 2409 2410 2411 - :issue:`7631`: The result type of :meth:`capfd.readouterr() <pytest.CaptureFixture.readouterr>` (and similar) is no longer a namedtuple, 2412 but should behave like one in all respects. This was done for technical reasons. 2413 2414 2415 - :issue:`7671`: When collecting tests, pytest finds test classes and functions by examining the 2416 attributes of python objects (modules, classes and instances). To speed up this 2417 process, pytest now ignores builtin attributes (like ``__class__``, 2418 ``__delattr__`` and ``__new__``) without consulting the :confval:`python_classes` and 2419 :confval:`python_functions` configuration options and without passing them to plugins 2420 using the :hook:`pytest_pycollect_makeitem` hook. 2421 2422 2423 pytest 6.0.2 (2020-09-04) 2424 ========================= 2425 2426 Bug Fixes 2427 --------- 2428 2429 - :issue:`7148`: Fixed ``--log-cli`` potentially causing unrelated ``print`` output to be swallowed. 2430 2431 2432 - :issue:`7672`: Fixed log-capturing level restored incorrectly if ``caplog.set_level`` is called more than once. 2433 2434 2435 - :issue:`7686`: Fixed `NotSetType.token` being used as the parameter ID when the parametrization list is empty. 2436 Regressed in pytest 6.0.0. 2437 2438 2439 - :issue:`7707`: Fix internal error when handling some exceptions that contain multiple lines or the style uses multiple lines (``--tb=line`` for example). 2440 2441 2442 pytest 6.0.1 (2020-07-30) 2443 ========================= 2444 2445 Bug Fixes 2446 --------- 2447 2448 - :issue:`7394`: Passing an empty ``help`` value to ``Parser.add_option`` is now accepted instead of crashing when running ``pytest --help``. 2449 Passing ``None`` raises a more informative ``TypeError``. 2450 2451 2452 - :issue:`7558`: Fix pylint ``not-callable`` lint on ``pytest.mark.parametrize()`` and the other builtin marks: 2453 ``skip``, ``skipif``, ``xfail``, ``usefixtures``, ``filterwarnings``. 2454 2455 2456 - :issue:`7559`: Fix regression in plugins using ``TestReport.longreprtext`` (such as ``pytest-html``) when ``TestReport.longrepr`` is not a string. 2457 2458 2459 - :issue:`7569`: Fix logging capture handler's level not reset on teardown after a call to ``caplog.set_level()``. 2460 2461 2462 pytest 6.0.0 (2020-07-28) 2463 ========================= 2464 2465 (**Please see the full set of changes for this release also in the 6.0.0rc1 notes below**) 2466 2467 Breaking Changes 2468 ---------------- 2469 2470 - :issue:`5584`: **PytestDeprecationWarning are now errors by default.** 2471 2472 Following our plan to remove deprecated features with as little disruption as 2473 possible, all warnings of type ``PytestDeprecationWarning`` now generate errors 2474 instead of warning messages. 2475 2476 **The affected features will be effectively removed in pytest 6.1**, so please consult the 2477 :std:doc:`deprecations` section in the docs for directions on how to update existing code. 2478 2479 In the pytest ``6.0.X`` series, it is possible to change the errors back into warnings as a 2480 stopgap measure by adding this to your ``pytest.ini`` file: 2481 2482 .. code-block:: ini 2483 2484 [pytest] 2485 filterwarnings = 2486 ignore::pytest.PytestDeprecationWarning 2487 2488 But this will stop working when pytest ``6.1`` is released. 2489 2490 **If you have concerns** about the removal of a specific feature, please add a 2491 comment to :issue:`5584`. 2492 2493 2494 - :issue:`7472`: The ``exec_()`` and ``is_true()`` methods of ``_pytest._code.Frame`` have been removed. 2495 2496 2497 2498 Features 2499 -------- 2500 2501 - :issue:`7464`: Added support for :envvar:`NO_COLOR` and :envvar:`FORCE_COLOR` environment variables to control colored output. 2502 2503 2504 2505 Improvements 2506 ------------ 2507 2508 - :issue:`7467`: ``--log-file`` CLI option and ``log_file`` ini marker now create subdirectories if needed. 2509 2510 2511 - :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. 2512 2513 2514 2515 Bug Fixes 2516 --------- 2517 2518 - :issue:`7392`: Fix the reported location of tests skipped with ``@pytest.mark.skip`` when ``--runxfail`` is used. 2519 2520 2521 - :issue:`7491`: :fixture:`tmpdir` and :fixture:`tmp_path` no longer raise an error if the lock to check for 2522 stale temporary directories is not accessible. 2523 2524 2525 - :issue:`7517`: Preserve line endings when captured via ``capfd``. 2526 2527 2528 - :issue:`7534`: Restored the previous formatting of ``TracebackEntry.__str__`` which was changed by accident. 2529 2530 2531 2532 Improved Documentation 2533 ---------------------- 2534 2535 - :issue:`7422`: Clarified when the ``usefixtures`` mark can apply fixtures to test. 2536 2537 2538 - :issue:`7441`: Add a note about ``-q`` option used in getting started guide. 2539 2540 2541 2542 Trivial/Internal Changes 2543 ------------------------ 2544 2545 - :issue:`7389`: Fixture scope ``package`` is no longer considered experimental. 2546 2547 2548 pytest 6.0.0rc1 (2020-07-08) 2549 ============================ 2550 2551 Breaking Changes 2552 ---------------- 2553 2554 - :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)``. 2555 2556 2557 - :issue:`5965`: symlinks are no longer resolved during collection and matching `conftest.py` files with test file paths. 2558 2559 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. 2560 2561 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 2562 :pull:`6523` for details). 2563 2564 This might break test suites which made use of this feature; the fix is to create a symlink 2565 for the entire test tree, and not only to partial files/tress as it was possible previously. 2566 2567 2568 - :issue:`6505`: ``Testdir.run().parseoutcomes()`` now always returns the parsed nouns in plural form. 2569 2570 Originally ``parseoutcomes()`` would always returns the nouns in plural form, but a change 2571 meant to improve the terminal summary by using singular form single items (``1 warning`` or ``1 error``) 2572 caused an unintended regression by changing the keys returned by ``parseoutcomes()``. 2573 2574 Now the API guarantees to always return the plural form, so calls like this: 2575 2576 .. code-block:: python 2577 2578 result = testdir.runpytest() 2579 result.assert_outcomes(error=1) 2580 2581 Need to be changed to: 2582 2583 2584 .. code-block:: python 2585 2586 result = testdir.runpytest() 2587 result.assert_outcomes(errors=1) 2588 2589 2590 - :issue:`6903`: The ``os.dup()`` function is now assumed to exist. We are not aware of any 2591 supported Python 3 implementations which do not provide it. 2592 2593 2594 - :issue:`7040`: ``-k`` no longer matches against the names of the directories outside the test session root. 2595 2596 Also, ``pytest.Package.name`` is now just the name of the directory containing the package's 2597 ``__init__.py`` file, instead of the full path. This is consistent with how the other nodes 2598 are named, and also one of the reasons why ``-k`` would match against any directory containing 2599 the test suite. 2600 2601 2602 - :issue:`7122`: Expressions given to the ``-m`` and ``-k`` options are no longer evaluated using Python's :func:`eval`. 2603 The format supports ``or``, ``and``, ``not``, parenthesis and general identifiers to match against. 2604 Python constants, keywords or other operators are no longer evaluated differently. 2605 2606 2607 - :issue:`7135`: Pytest now uses its own ``TerminalWriter`` class instead of using the one from the ``py`` library. 2608 Plugins generally access this class through ``TerminalReporter.writer``, ``TerminalReporter.write()`` 2609 (and similar methods), or ``_pytest.config.create_terminal_writer()``. 2610 2611 The following breaking changes were made: 2612 2613 - Output (``write()`` method and others) no longer flush implicitly; the flushing behavior 2614 of the underlying file is respected. To flush explicitly (for example, if you 2615 want output to be shown before an end-of-line is printed), use ``write(flush=True)`` or 2616 ``terminal_writer.flush()``. 2617 - Explicit Windows console support was removed, delegated to the colorama library. 2618 - Support for writing ``bytes`` was removed. 2619 - The ``reline`` method and ``chars_on_current_line`` property were removed. 2620 - The ``stringio`` and ``encoding`` arguments was removed. 2621 - Support for passing a callable instead of a file was removed. 2622 2623 2624 - :issue:`7224`: The `item.catch_log_handler` and `item.catch_log_handlers` attributes, set by the 2625 logging plugin and never meant to be public, are no longer available. 2626 2627 The deprecated ``--no-print-logs`` option and ``log_print`` ini option are removed. Use ``--show-capture`` instead. 2628 2629 2630 - :issue:`7226`: Removed the unused ``args`` parameter from ``pytest.Function.__init__``. 2631 2632 2633 - :issue:`7418`: Removed the `pytest_doctest_prepare_content` hook specification. This hook 2634 hasn't been triggered by pytest for at least 10 years. 2635 2636 2637 - :issue:`7438`: Some changes were made to the internal ``_pytest._code.source``, listed here 2638 for the benefit of plugin authors who may be using it: 2639 2640 - The ``deindent`` argument to ``Source()`` has been removed, now it is always true. 2641 - Support for zero or multiple arguments to ``Source()`` has been removed. 2642 - Support for comparing ``Source`` with an ``str`` has been removed. 2643 - The methods ``Source.isparseable()`` and ``Source.putaround()`` have been removed. 2644 - The method ``Source.compile()`` and function ``_pytest._code.compile()`` have 2645 been removed; use plain ``compile()`` instead. 2646 - The function ``_pytest._code.source.getsource()`` has been removed; use 2647 ``Source()`` directly instead. 2648 2649 2650 2651 Deprecations 2652 ------------ 2653 2654 - :issue:`7210`: The special ``-k '-expr'`` syntax to ``-k`` is deprecated. Use ``-k 'not expr'`` 2655 instead. 2656 2657 The special ``-k 'expr:'`` syntax to ``-k`` is deprecated. Please open an issue 2658 if you use this and want a replacement. 2659 2660 - :issue:`4049`: ``pytest_warning_captured`` is deprecated in favor of the ``pytest_warning_recorded`` hook. 2661 2662 2663 Features 2664 -------- 2665 2666 - :issue:`1556`: pytest now supports ``pyproject.toml`` files for configuration. 2667 2668 The configuration options is similar to the one available in other formats, but must be defined 2669 in a ``[tool.pytest.ini_options]`` table to be picked up by pytest: 2670 2671 .. code-block:: toml 2672 2673 # pyproject.toml 2674 [tool.pytest.ini_options] 2675 minversion = "6.0" 2676 addopts = "-ra -q" 2677 testpaths = [ 2678 "tests", 2679 "integration", 2680 ] 2681 2682 More information can be found :ref:`in the docs <config file formats>`. 2683 2684 2685 - :issue:`3342`: pytest now includes inline type annotations and exposes them to user programs. 2686 Most of the user-facing API is covered, as well as internal code. 2687 2688 If you are running a type checker such as mypy on your tests, you may start 2689 noticing type errors indicating incorrect usage. If you run into an error that 2690 you believe to be incorrect, please let us know in an issue. 2691 2692 The types were developed against mypy version 0.780. Versions before 0.750 2693 are known not to work. We recommend using the latest version. Other type 2694 checkers may work as well, but they are not officially verified to work by 2695 pytest yet. 2696 2697 2698 - :issue:`4049`: Introduced a new hook named `pytest_warning_recorded` to convey information about warnings captured by the internal `pytest` warnings plugin. 2699 2700 This hook is meant to replace `pytest_warning_captured`, which is deprecated and will be removed in a future release. 2701 2702 2703 - :issue:`6471`: New command-line flags: 2704 2705 * `--no-header`: disables the initial header, including platform, version, and plugins. 2706 * `--no-summary`: disables the final test summary, including warnings. 2707 2708 2709 - :issue:`6856`: A warning is now shown when an unknown key is read from a config INI file. 2710 2711 The `--strict-config` flag has been added to treat these warnings as errors. 2712 2713 2714 - :issue:`6906`: Added `--code-highlight` command line option to enable/disable code highlighting in terminal output. 2715 2716 2717 - :issue:`7245`: New ``--import-mode=importlib`` option that uses :mod:`importlib` to import test modules. 2718 2719 Traditionally pytest used ``__import__`` while changing ``sys.path`` to import test modules (which 2720 also changes ``sys.modules`` as a side-effect), which works but has a number of drawbacks, like requiring test modules 2721 that don't live in packages to have unique names (as they need to reside under a unique name in ``sys.modules``). 2722 2723 ``--import-mode=importlib`` uses more fine-grained import mechanisms from ``importlib`` which don't 2724 require pytest to change ``sys.path`` or ``sys.modules`` at all, eliminating much of the drawbacks 2725 of the previous mode. 2726 2727 We intend to make ``--import-mode=importlib`` the default in future versions, so users are encouraged 2728 to try the new mode and provide feedback (both positive or negative) in issue :issue:`7245`. 2729 2730 You can read more about this option in :std:ref:`the documentation <import-modes>`. 2731 2732 2733 - :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. 2734 2735 2736 Improvements 2737 ------------ 2738 2739 - :issue:`4375`: The ``pytest`` command now suppresses the ``BrokenPipeError`` error message that 2740 is printed to stderr when the output of ``pytest`` is piped and the pipe is 2741 closed by the piped-to program (common examples are ``less`` and ``head``). 2742 2743 2744 - :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()``). 2745 2746 2747 - :issue:`4675`: Rich comparison for dataclasses and `attrs`-classes is now recursive. 2748 2749 2750 - :issue:`6285`: Exposed the `pytest.FixtureLookupError` exception which is raised by `request.getfixturevalue()` 2751 (where `request` is a `FixtureRequest` fixture) when a fixture with the given name cannot be returned. 2752 2753 2754 - :issue:`6433`: If an error is encountered while formatting the message in a logging call, for 2755 example ``logging.warning("oh no!: %s: %s", "first")`` (a second argument is 2756 missing), pytest now propagates the error, likely causing the test to fail. 2757 2758 Previously, such a mistake would cause an error to be printed to stderr, which 2759 is not displayed by default for passing tests. This change makes the mistake 2760 visible during testing. 2761 2762 You may suppress this behavior temporarily or permanently by setting 2763 ``logging.raiseExceptions = False``. 2764 2765 2766 - :issue:`6817`: Explicit new-lines in help texts of command-line options are preserved, allowing plugins better control 2767 of the help displayed to users. 2768 2769 2770 - :issue:`6940`: When using the ``--duration`` option, the terminal message output is now more precise about the number and duration of hidden items. 2771 2772 2773 - :issue:`6991`: Collected files are displayed after any reports from hooks, e.g. the status from ``--lf``. 2774 2775 2776 - :issue:`7091`: When ``fd`` capturing is used, through ``--capture=fd`` or the ``capfd`` and 2777 ``capfdbinary`` fixtures, and the file descriptor (0, 1, 2) cannot be 2778 duplicated, FD capturing is still performed. Previously, direct writes to the 2779 file descriptors would fail or be lost in this case. 2780 2781 2782 - :issue:`7119`: Exit with an error if the ``--basetemp`` argument is empty, is the current working directory or is one of the parent directories. 2783 This is done to protect against accidental data loss, as any directory passed to this argument is cleared. 2784 2785 2786 - :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`. 2787 2788 2789 - :issue:`7133`: :meth:`caplog.set_level() <pytest.LogCaptureFixture.set_level>` will now override any :confval:`log_level` set via the CLI or configuration file. 2790 2791 2792 - :issue:`7159`: :meth:`caplog.set_level() <pytest.LogCaptureFixture.set_level>` and :meth:`caplog.at_level() <pytest.LogCaptureFixture.at_level>` no longer affect 2793 the level of logs that are shown in the *Captured log report* report section. 2794 2795 2796 - :issue:`7348`: Improve recursive diff report for comparison asserts on dataclasses / attrs. 2797 2798 2799 - :issue:`7385`: ``--junitxml`` now includes the exception cause in the ``message`` XML attribute for failures during setup and teardown. 2800 2801 Previously: 2802 2803 .. code-block:: xml 2804 2805 <error message="test setup failure"> 2806 2807 Now: 2808 2809 .. code-block:: xml 2810 2811 <error message="failed on setup with "ValueError: Some error during setup""> 2812 2813 2814 2815 Bug Fixes 2816 --------- 2817 2818 - :issue:`1120`: Fix issue where directories from :fixture:`tmpdir` are not removed properly when multiple instances of pytest are running in parallel. 2819 2820 2821 - :issue:`4583`: Prevent crashing and provide a user-friendly error when a marker expression (`-m`) invoking of :func:`eval` raises any exception. 2822 2823 2824 - :issue:`4677`: The path shown in the summary report for SKIPPED tests is now always relative. Previously it was sometimes absolute. 2825 2826 2827 - :issue:`5456`: Fix a possible race condition when trying to remove lock files used to control access to folders 2828 created by :fixture:`tmp_path` and :fixture:`tmpdir`. 2829 2830 2831 - :issue:`6240`: Fixes an issue where logging during collection step caused duplication of log 2832 messages to stderr. 2833 2834 2835 - :issue:`6428`: Paths appearing in error messages are now correct in case the current working directory has 2836 changed since the start of the session. 2837 2838 2839 - :issue:`6755`: Support deleting paths longer than 260 characters on windows created inside :fixture:`tmpdir`. 2840 2841 2842 - :issue:`6871`: Fix crash with captured output when using :fixture:`capsysbinary`. 2843 2844 2845 - :issue:`6909`: Revert the change introduced by :pull:`6330`, which required all arguments to ``@pytest.mark.parametrize`` to be explicitly defined in the function signature. 2846 2847 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. 2848 2849 2850 - :issue:`6910`: Fix crash when plugins return an unknown stats while using the ``--reportlog`` option. 2851 2852 2853 - :issue:`6924`: Ensure a ``unittest.IsolatedAsyncioTestCase`` is actually awaited. 2854 2855 2856 - :issue:`6925`: Fix `TerminalRepr` instances to be hashable again. 2857 2858 2859 - :issue:`6947`: Fix regression where functions registered with :meth:`unittest.TestCase.addCleanup` were not being called on test failures. 2860 2861 2862 - :issue:`6951`: Allow users to still set the deprecated ``TerminalReporter.writer`` attribute. 2863 2864 2865 - :issue:`6956`: Prevent pytest from printing `ConftestImportFailure` traceback to stdout. 2866 2867 2868 - :issue:`6991`: Fix regressions with `--lf` filtering too much since pytest 5.4. 2869 2870 2871 - :issue:`6992`: Revert "tmpdir: clean up indirection via config for factories" :issue:`6767` as it breaks pytest-xdist. 2872 2873 2874 - :issue:`7061`: When a yielding fixture fails to yield a value, report a test setup error instead of crashing. 2875 2876 2877 - :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. 2878 2879 2880 - :issue:`7110`: Fixed regression: ``asyncbase.TestCase`` tests are executed correctly again. 2881 2882 2883 - :issue:`7126`: ``--setup-show`` now doesn't raise an error when a bytes value is used as a ``parametrize`` 2884 parameter when Python is called with the ``-bb`` flag. 2885 2886 2887 - :issue:`7143`: Fix :meth:`pytest.File.from_parent <_pytest.nodes.Node.from_parent>` so it forwards extra keyword arguments to the constructor. 2888 2889 2890 - :issue:`7145`: Classes with broken ``__getattribute__`` methods are displayed correctly during failures. 2891 2892 2893 - :issue:`7150`: Prevent hiding the underlying exception when ``ConfTestImportFailure`` is raised. 2894 2895 2896 - :issue:`7180`: Fix ``_is_setup_py`` for files encoded differently than locale. 2897 2898 2899 - :issue:`7215`: Fix regression where running with ``--pdb`` would call :meth:`unittest.TestCase.tearDown` for skipped tests. 2900 2901 2902 - :issue:`7253`: When using ``pytest.fixture`` on a function directly, as in ``pytest.fixture(func)``, 2903 if the ``autouse`` or ``params`` arguments are also passed, the function is no longer 2904 ignored, but is marked as a fixture. 2905 2906 2907 - :issue:`7360`: Fix possibly incorrect evaluation of string expressions passed to ``pytest.mark.skipif`` and ``pytest.mark.xfail``, 2908 in rare circumstances where the exact same string is used but refers to different global values. 2909 2910 2911 - :issue:`7383`: Fixed exception causes all over the codebase, i.e. use `raise new_exception from old_exception` when wrapping an exception. 2912 2913 2914 2915 Improved Documentation 2916 ---------------------- 2917 2918 - :issue:`7202`: The development guide now links to the contributing section of the docs and `RELEASING.rst` on GitHub. 2919 2920 2921 - :issue:`7233`: Add a note about ``--strict`` and ``--strict-markers`` and the preference for the latter one. 2922 2923 2924 - :issue:`7345`: Explain indirect parametrization and markers for fixtures. 2925 2926 2927 2928 Trivial/Internal Changes 2929 ------------------------ 2930 2931 - :issue:`7035`: The ``originalname`` attribute of ``_pytest.python.Function`` now defaults to ``name`` if not 2932 provided explicitly, and is always set. 2933 2934 2935 - :issue:`7264`: The dependency on the ``wcwidth`` package has been removed. 2936 2937 2938 - :issue:`7291`: Replaced ``py.iniconfig`` with :pypi:`iniconfig`. 2939 2940 2941 - :issue:`7295`: ``src/_pytest/config/__init__.py`` now uses the ``warnings`` module to report warnings instead of ``sys.stderr.write``. 2942 2943 2944 - :issue:`7356`: Remove last internal uses of deprecated *slave* term from old ``pytest-xdist``. 2945 2946 2947 - :issue:`7357`: ``py``>=1.8.2 is now required. 2948 2949 2950 pytest 5.4.3 (2020-06-02) 2951 ========================= 2952 2953 Bug Fixes 2954 --------- 2955 2956 - :issue:`6428`: Paths appearing in error messages are now correct in case the current working directory has 2957 changed since the start of the session. 2958 2959 2960 - :issue:`6755`: Support deleting paths longer than 260 characters on windows created inside tmpdir. 2961 2962 2963 - :issue:`6956`: Prevent pytest from printing ConftestImportFailure traceback to stdout. 2964 2965 2966 - :issue:`7150`: Prevent hiding the underlying exception when ``ConfTestImportFailure`` is raised. 2967 2968 2969 - :issue:`7215`: Fix regression where running with ``--pdb`` would call the ``tearDown`` methods of ``unittest.TestCase`` 2970 subclasses for skipped tests. 2971 2972 2973 pytest 5.4.2 (2020-05-08) 2974 ========================= 2975 2976 Bug Fixes 2977 --------- 2978 2979 - :issue:`6871`: Fix crash with captured output when using the :fixture:`capsysbinary fixture <capsysbinary>`. 2980 2981 2982 - :issue:`6924`: Ensure a ``unittest.IsolatedAsyncioTestCase`` is actually awaited. 2983 2984 2985 - :issue:`6925`: Fix TerminalRepr instances to be hashable again. 2986 2987 2988 - :issue:`6947`: Fix regression where functions registered with ``TestCase.addCleanup`` were not being called on test failures. 2989 2990 2991 - :issue:`6951`: Allow users to still set the deprecated ``TerminalReporter.writer`` attribute. 2992 2993 2994 - :issue:`6992`: Revert "tmpdir: clean up indirection via config for factories" #6767 as it breaks pytest-xdist. 2995 2996 2997 - :issue:`7110`: Fixed regression: ``asyncbase.TestCase`` tests are executed correctly again. 2998 2999 3000 - :issue:`7143`: Fix ``File.from_parent`` so it forwards extra keyword arguments to the constructor. 3001 3002 3003 - :issue:`7145`: Classes with broken ``__getattribute__`` methods are displayed correctly during failures. 3004 3005 3006 - :issue:`7180`: Fix ``_is_setup_py`` for files encoded differently than locale. 3007 3008 3009 pytest 5.4.1 (2020-03-13) 3010 ========================= 3011 3012 Bug Fixes 3013 --------- 3014 3015 - :issue:`6909`: Revert the change introduced by :pull:`6330`, which required all arguments to ``@pytest.mark.parametrize`` to be explicitly defined in the function signature. 3016 3017 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. 3018 3019 3020 - :issue:`6910`: Fix crash when plugins return an unknown stats while using the ``--reportlog`` option. 3021 3022 3023 pytest 5.4.0 (2020-03-12) 3024 ========================= 3025 3026 Breaking Changes 3027 ---------------- 3028 3029 - :issue:`6316`: Matching of ``-k EXPRESSION`` to test names is now case-insensitive. 3030 3031 3032 - :issue:`6443`: Plugins specified with ``-p`` are now loaded after internal plugins, which results in their hooks being called *before* the internal ones. 3033 3034 This makes the ``-p`` behavior consistent with ``PYTEST_PLUGINS``. 3035 3036 3037 - :issue:`6637`: Removed the long-deprecated ``pytest_itemstart`` hook. 3038 3039 This hook has been marked as deprecated and not been even called by pytest for over 10 years now. 3040 3041 3042 - :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. 3043 3044 3045 - :issue:`6737`: The ``cached_result`` attribute of ``FixtureDef`` is now set to ``None`` when 3046 the result is unavailable, instead of being deleted. 3047 3048 If your plugin performs checks like ``hasattr(fixturedef, 'cached_result')``, 3049 for example in a ``pytest_fixture_post_finalizer`` hook implementation, replace 3050 it with ``fixturedef.cached_result is not None``. If you ``del`` the attribute, 3051 set it to ``None`` instead. 3052 3053 3054 3055 Deprecations 3056 ------------ 3057 3058 - :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 3059 provide feedback. 3060 3061 ``--show-capture`` command-line option was added in ``pytest 3.5.0`` and allows to specify how to 3062 display captured output when tests fail: ``no``, ``stdout``, ``stderr``, ``log`` or ``all`` (the default). 3063 3064 3065 - :issue:`571`: Deprecate the unused/broken `pytest_collect_directory` hook. 3066 It was misaligned since the removal of the ``Directory`` collector in 2010 3067 and incorrect/unusable as soon as collection was split from test execution. 3068 3069 3070 - :issue:`5975`: Deprecate using direct constructors for ``Nodes``. 3071 3072 Instead they are now constructed via ``Node.from_parent``. 3073 3074 This transitional mechanism enables us to untangle the very intensely 3075 entangled ``Node`` relationships by enforcing more controlled creation/configuration patterns. 3076 3077 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. 3078 3079 Subclasses are expected to use `super().from_parent` if they intend to expand the creation of `Nodes`. 3080 3081 3082 - :issue:`6779`: The ``TerminalReporter.writer`` attribute has been deprecated and should no longer be used. This 3083 was inadvertently exposed as part of the public API of that plugin and ties it too much 3084 with ``py.io.TerminalWriter``. 3085 3086 3087 3088 Features 3089 -------- 3090 3091 - :issue:`4597`: New :ref:`--capture=tee-sys <capture-method>` option to allow both live printing and capturing of test output. 3092 3093 3094 - :issue:`5712`: Now all arguments to ``@pytest.mark.parametrize`` need to be explicitly declared in the function signature or via ``indirect``. 3095 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. 3096 3097 3098 - :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). 3099 3100 3101 - :issue:`6469`: New options have been added to the :confval:`junit_logging` option: ``log``, ``out-err``, and ``all``. 3102 3103 3104 - :issue:`6834`: Excess warning summaries are now collapsed per file to ensure readable display of warning summaries. 3105 3106 3107 3108 Improvements 3109 ------------ 3110 3111 - :issue:`1857`: ``pytest.mark.parametrize`` accepts integers for ``ids`` again, converting it to strings. 3112 3113 3114 - :issue:`449`: Use "yellow" main color with any XPASSED tests. 3115 3116 3117 - :issue:`4639`: Revert "A warning is now issued when assertions are made for ``None``". 3118 3119 The warning proved to be less useful than initially expected and had quite a 3120 few false positive cases. 3121 3122 3123 - :issue:`5686`: ``tmpdir_factory.mktemp`` now fails when given absolute and non-normalized paths. 3124 3125 3126 - :issue:`5984`: The ``pytest_warning_captured`` hook now receives a ``location`` parameter with the code location that generated the warning. 3127 3128 3129 - :issue:`6213`: pytester: the ``testdir`` fixture respects environment settings from the ``monkeypatch`` fixture for inner runs. 3130 3131 3132 - :issue:`6247`: ``--fulltrace`` is honored with collection errors. 3133 3134 3135 - :issue:`6384`: Make `--showlocals` work also with `--tb=short`. 3136 3137 3138 - :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`. 3139 3140 3141 - :issue:`6658`: Code is now highlighted in tracebacks when ``pygments`` is installed. 3142 3143 Users are encouraged to install ``pygments`` into their environment and provide feedback, because 3144 the plan is to make ``pygments`` a regular dependency in the future. 3145 3146 3147 - :issue:`6795`: Import usage error message with invalid `-o` option. 3148 3149 3150 - :issue:`759`: ``pytest.mark.parametrize`` supports iterators and generators for ``ids``. 3151 3152 3153 3154 Bug Fixes 3155 --------- 3156 3157 - :issue:`310`: Add support for calling `pytest.xfail()` and `pytest.importorskip()` with doctests. 3158 3159 3160 - :issue:`3823`: ``--trace`` now works with unittests. 3161 3162 3163 - :issue:`4445`: Fixed some warning reports produced by pytest to point to the correct location of the warning in the user's code. 3164 3165 3166 - :issue:`5301`: Fix ``--last-failed`` to collect new tests from files with known failures. 3167 3168 3169 - :issue:`5928`: Report ``PytestUnknownMarkWarning`` at the level of the user's code, not ``pytest``'s. 3170 3171 3172 - :issue:`5991`: Fix interaction with ``--pdb`` and unittests: do not use unittest's ``TestCase.debug()``. 3173 3174 3175 - :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``). 3176 3177 The upper case variants were never documented and the preferred form should be the lower case. 3178 3179 3180 - :issue:`6409`: Fallback to green (instead of yellow) for non-last items without previous passes with colored terminal progress indicator. 3181 3182 3183 - :issue:`6454`: `--disable-warnings` is honored with `-ra` and `-rA`. 3184 3185 3186 - :issue:`6497`: Fix bug in the comparison of request key with cached key in fixture. 3187 3188 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`. 3189 The implemented fix replaces `==` with ``is``. 3190 3191 3192 - :issue:`6557`: Make capture output streams ``.write()`` method return the same return value from original streams. 3193 3194 3195 - :issue:`6566`: Fix ``EncodedFile.writelines`` to call the underlying buffer's ``writelines`` method. 3196 3197 3198 - :issue:`6575`: Fix internal crash when ``faulthandler`` starts initialized 3199 (for example with ``PYTHONFAULTHANDLER=1`` environment variable set) and ``faulthandler_timeout`` defined 3200 in the configuration file. 3201 3202 3203 - :issue:`6597`: Fix node ids which contain a parametrized empty-string variable. 3204 3205 3206 - :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. 3207 3208 3209 - :issue:`6660`: :py:func:`pytest.exit` is handled when emitted from the :hook:`pytest_sessionfinish` hook. This includes quitting from a debugger. 3210 3211 3212 - :issue:`6752`: When :py:func:`pytest.raises` is used as a function (as opposed to a context manager), 3213 a `match` keyword argument is now passed through to the tested function. Previously 3214 it was swallowed and ignored (regression in pytest 5.1.0). 3215 3216 3217 - :issue:`6801`: Do not display empty lines in between traceback for unexpected exceptions with doctests. 3218 3219 3220 - :issue:`6802`: The :fixture:`testdir fixture <testdir>` works within doctests now. 3221 3222 3223 3224 Improved Documentation 3225 ---------------------- 3226 3227 - :issue:`6696`: Add list of fixtures to start of fixture chapter. 3228 3229 3230 - :issue:`6742`: Expand first sentence on fixtures into a paragraph. 3231 3232 3233 3234 Trivial/Internal Changes 3235 ------------------------ 3236 3237 - :issue:`6404`: Remove usage of ``parser`` module, deprecated in Python 3.9. 3238 3239 3240 pytest 5.3.5 (2020-01-29) 3241 ========================= 3242 3243 Bug Fixes 3244 --------- 3245 3246 - :issue:`6517`: Fix regression in pytest 5.3.4 causing an INTERNALERROR due to a wrong assertion. 3247 3248 3249 pytest 5.3.4 (2020-01-20) 3250 ========================= 3251 3252 Bug Fixes 3253 --------- 3254 3255 - :issue:`6496`: Revert :issue:`6436`: unfortunately this change has caused a number of regressions in many suites, 3256 so the team decided to revert this change and make a new release while we continue to look for a solution. 3257 3258 3259 pytest 5.3.3 (2020-01-16) 3260 ========================= 3261 3262 Bug Fixes 3263 --------- 3264 3265 - :issue:`2780`: Captured output during teardown is shown with ``-rP``. 3266 3267 3268 - :issue:`5971`: Fix a ``pytest-xdist`` crash when dealing with exceptions raised in subprocesses created by the 3269 ``multiprocessing`` module. 3270 3271 3272 - :issue:`6436`: :class:`~pytest.FixtureDef` objects now properly register their finalizers with autouse and 3273 parameterized fixtures that execute before them in the fixture stack so they are torn 3274 down at the right times, and in the right order. 3275 3276 3277 - :issue:`6532`: Fix parsing of outcomes containing multiple errors with ``testdir`` results (regression in 5.3.0). 3278 3279 3280 3281 Trivial/Internal Changes 3282 ------------------------ 3283 3284 - :issue:`6350`: Optimized automatic renaming of test parameter IDs. 3285 3286 3287 pytest 5.3.2 (2019-12-13) 3288 ========================= 3289 3290 Improvements 3291 ------------ 3292 3293 - :issue:`4639`: Revert "A warning is now issued when assertions are made for ``None``". 3294 3295 The warning proved to be less useful than initially expected and had quite a 3296 few false positive cases. 3297 3298 3299 3300 Bug Fixes 3301 --------- 3302 3303 - :issue:`5430`: junitxml: Logs for failed test are now passed to junit report in case the test fails during call phase. 3304 3305 3306 - :issue:`6290`: The supporting files in the ``.pytest_cache`` directory are kept with ``--cache-clear``, which only clears cached values now. 3307 3308 3309 - :issue:`6301`: Fix assertion rewriting for egg-based distributions and ``editable`` installs (``pip install --editable``). 3310 3311 3312 pytest 5.3.1 (2019-11-25) 3313 ========================= 3314 3315 Improvements 3316 ------------ 3317 3318 - :issue:`6231`: Improve check for misspelling of :ref:`pytest.mark.parametrize ref`. 3319 3320 3321 - :issue:`6257`: Handle :func:`pytest.exit` being used via :hook:`pytest_internalerror`, e.g. when quitting pdb from post mortem. 3322 3323 3324 3325 Bug Fixes 3326 --------- 3327 3328 - :issue:`5914`: pytester: fix :py:func:`~pytest.LineMatcher.no_fnmatch_line` when used after positive matching. 3329 3330 3331 - :issue:`6082`: Fix line detection for doctest samples inside :py:class:`python:property` docstrings, as a workaround to :bpo:`17446`. 3332 3333 3334 - :issue:`6254`: Fix compatibility with pytest-parallel (regression in pytest 5.3.0). 3335 3336 3337 - :issue:`6255`: Clear the :py:data:`sys.last_traceback`, :py:data:`sys.last_type` 3338 and :py:data:`sys.last_value` attributes by deleting them instead 3339 of setting them to ``None``. This better matches the behaviour of 3340 the Python standard library. 3341 3342 3343 pytest 5.3.0 (2019-11-19) 3344 ========================= 3345 3346 Deprecations 3347 ------------ 3348 3349 - :issue:`6179`: The default value of :confval:`junit_family` option will change to ``"xunit2"`` in pytest 6.0, given 3350 that this is the version supported by default in modern tools that manipulate this type of file. 3351 3352 In order to smooth the transition, pytest will issue a warning in case the ``--junitxml`` option 3353 is given in the command line but :confval:`junit_family` is not explicitly configured in ``pytest.ini``. 3354 3355 For more information, :ref:`see the docs <junit-family changed default value>`. 3356 3357 3358 3359 Features 3360 -------- 3361 3362 - :issue:`4488`: The pytest team has created the `pytest-reportlog <https://github.com/pytest-dev/pytest-reportlog>`__ 3363 plugin, which provides a new ``--report-log=FILE`` option that writes *report logs* into a file as the test session executes. 3364 3365 Each line of the report log contains a self contained JSON object corresponding to a testing event, 3366 such as a collection or a test result report. The file is guaranteed to be flushed after writing 3367 each line, so systems can read and process events in real-time. 3368 3369 The plugin is meant to replace the ``--resultlog`` option, which is deprecated and meant to be removed 3370 in a future release. If you use ``--resultlog``, please try out ``pytest-reportlog`` and 3371 provide feedback. 3372 3373 3374 - :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. 3375 3376 This makes it easier to benefit of cached ``.pyc`` files even on file systems without permissions. 3377 3378 3379 - :issue:`5515`: Allow selective auto-indentation of multiline log messages. 3380 3381 Adds command line option ``--log-auto-indent``, config option 3382 :confval:`log_auto_indent` and support for per-entry configuration of 3383 indentation behavior on calls to :py:func:`python:logging.log()`. 3384 3385 Alters the default for auto-indention from ``"on"`` to ``"off"``. This 3386 restores the older behavior that existed prior to v4.6.0. This 3387 reversion to earlier behavior was done because it is better to 3388 activate new features that may lead to broken tests explicitly 3389 rather than implicitly. 3390 3391 3392 - :issue:`5914`: :fixture:`testdir` learned two new functions, :py:func:`~pytest.LineMatcher.no_fnmatch_line` and 3393 :py:func:`~pytest.LineMatcher.no_re_match_line`. 3394 3395 The functions are used to ensure the captured text *does not* match the given 3396 pattern. 3397 3398 The previous idiom was to use :py:func:`python:re.match`: 3399 3400 .. code-block:: python 3401 3402 result = testdir.runpytest() 3403 assert re.match(pat, result.stdout.str()) is None 3404 3405 Or the ``in`` operator: 3406 3407 .. code-block:: python 3408 3409 result = testdir.runpytest() 3410 assert text in result.stdout.str() 3411 3412 But the new functions produce best output on failure. 3413 3414 3415 - :issue:`6057`: Added tolerances to complex values when printing ``pytest.approx``. 3416 3417 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. 3418 3419 3420 - :issue:`6061`: Added the pluginmanager as an argument to ``pytest_addoption`` 3421 so that hooks can be invoked when setting up command line options. This is 3422 useful for having one plugin communicate things to another plugin, 3423 such as default values or which set of command line options to add. 3424 3425 3426 3427 Improvements 3428 ------------ 3429 3430 - :issue:`5061`: Use multiple colors with terminal summary statistics. 3431 3432 3433 - :issue:`5630`: Quitting from debuggers is now properly handled in ``doctest`` items. 3434 3435 3436 - :issue:`5924`: Improved verbose diff output with sequences. 3437 3438 Before: 3439 3440 :: 3441 3442 E AssertionError: assert ['version', '...version_info'] == ['version', '...version', ...] 3443 E Right contains 3 more items, first extra item: ' ' 3444 E Full diff: 3445 E - ['version', 'version_info', 'sys.version', 'sys.version_info'] 3446 E + ['version', 3447 E + 'version_info', 3448 E + 'sys.version', 3449 E + 'sys.version_info', 3450 E + ' ', 3451 E + 'sys.version', 3452 E + 'sys.version_info'] 3453 3454 After: 3455 3456 :: 3457 3458 E AssertionError: assert ['version', '...version_info'] == ['version', '...version', ...] 3459 E Right contains 3 more items, first extra item: ' ' 3460 E Full diff: 3461 E [ 3462 E 'version', 3463 E 'version_info', 3464 E 'sys.version', 3465 E 'sys.version_info', 3466 E + ' ', 3467 E + 'sys.version', 3468 E + 'sys.version_info', 3469 E ] 3470 3471 3472 - :issue:`5934`: ``repr`` of ``ExceptionInfo`` objects has been improved to honor the ``__repr__`` method of the underlying exception. 3473 3474 - :issue:`5936`: Display untruncated assertion message with ``-vv``. 3475 3476 3477 - :issue:`5990`: Fixed plurality mismatch in test summary (e.g. display "1 error" instead of "1 errors"). 3478 3479 3480 - :issue:`6008`: ``Config.InvocationParams.args`` is now always a ``tuple`` to better convey that it should be 3481 immutable and avoid accidental modifications. 3482 3483 3484 - :issue:`6023`: ``pytest.main`` returns a ``pytest.ExitCode`` instance now, except for when custom exit codes are used (where it returns ``int`` then still). 3485 3486 3487 - :issue:`6026`: Align prefixes in output of pytester's ``LineMatcher``. 3488 3489 3490 - :issue:`6059`: Collection errors are reported as errors (and not failures like before) in the terminal's short test summary. 3491 3492 3493 - :issue:`6069`: ``pytester.spawn`` does not skip/xfail tests on FreeBSD anymore unconditionally. 3494 3495 3496 - :issue:`6097`: The "[...%]" indicator in the test summary is now colored according to the final (new) multi-colored line's main color. 3497 3498 3499 - :issue:`6116`: Added ``--co`` as a synonym to ``--collect-only``. 3500 3501 3502 - :issue:`6148`: ``atomicwrites`` is now only used on Windows, fixing a performance regression with assertion rewriting on Unix. 3503 3504 3505 - :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. 3506 3507 3508 - :issue:`6176`: Improved failure reporting with pytester's ``Hookrecorder.assertoutcome``. 3509 3510 3511 - :issue:`6181`: The reason for a stopped session, e.g. with ``--maxfail`` / ``-x``, now gets reported in the test summary. 3512 3513 3514 - :issue:`6206`: Improved ``cache.set`` robustness and performance. 3515 3516 3517 3518 Bug Fixes 3519 --------- 3520 3521 - :issue:`2049`: Fixed ``--setup-plan`` showing inaccurate information about fixture lifetimes. 3522 3523 3524 - :issue:`2548`: Fixed line offset mismatch of skipped tests in terminal summary. 3525 3526 3527 - :issue:`6039`: The ``PytestDoctestRunner`` is now properly invalidated when unconfiguring the doctest plugin. 3528 3529 This is important when used with ``pytester``'s ``runpytest_inprocess``. 3530 3531 3532 - :issue:`6047`: BaseExceptions are now handled in ``saferepr``, which includes ``pytest.fail.Exception`` etc. 3533 3534 3535 - :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``. 3536 3537 3538 - :issue:`6189`: Fixed result of ``getmodpath`` method. 3539 3540 3541 3542 Trivial/Internal Changes 3543 ------------------------ 3544 3545 - :issue:`4901`: ``RunResult`` from ``pytester`` now displays the mnemonic of the ``ret`` attribute when it is a 3546 valid ``pytest.ExitCode`` value. 3547 3548 3549 pytest 5.2.4 (2019-11-15) 3550 ========================= 3551 3552 Bug Fixes 3553 --------- 3554 3555 - :issue:`6194`: Fix incorrect discovery of non-test ``__init__.py`` files. 3556 3557 3558 - :issue:`6197`: Revert "The first test in a package (``__init__.py``) marked with ``@pytest.mark.skip`` is now correctly skipped.". 3559 3560 3561 pytest 5.2.3 (2019-11-14) 3562 ========================= 3563 3564 Bug Fixes 3565 --------- 3566 3567 - :issue:`5830`: The first test in a package (``__init__.py``) marked with ``@pytest.mark.skip`` is now correctly skipped. 3568 3569 3570 - :issue:`6099`: Fix ``--trace`` when used with parametrized functions. 3571 3572 3573 - :issue:`6183`: Using ``request`` as a parameter name in ``@pytest.mark.parametrize`` now produces a more 3574 user-friendly error. 3575 3576 3577 pytest 5.2.2 (2019-10-24) 3578 ========================= 3579 3580 Bug Fixes 3581 --------- 3582 3583 - :issue:`5206`: Fix ``--nf`` to not forget about known nodeids with partial test selection. 3584 3585 3586 - :issue:`5906`: Fix crash with ``KeyboardInterrupt`` during ``--setup-show``. 3587 3588 3589 - :issue:`5946`: Fixed issue when parametrizing fixtures with numpy arrays (and possibly other sequence-like types). 3590 3591 3592 - :issue:`6044`: Properly ignore ``FileNotFoundError`` exceptions when trying to remove old temporary directories, 3593 for instance when multiple processes try to remove the same directory (common with ``pytest-xdist`` 3594 for example). 3595 3596 3597 pytest 5.2.1 (2019-10-06) 3598 ========================= 3599 3600 Bug Fixes 3601 --------- 3602 3603 - :issue:`5902`: Fix warnings about deprecated ``cmp`` attribute in ``attrs>=19.2``. 3604 3605 3606 pytest 5.2.0 (2019-09-28) 3607 ========================= 3608 3609 Deprecations 3610 ------------ 3611 3612 - :issue:`1682`: Passing arguments to pytest.fixture() as positional arguments is deprecated - pass them 3613 as a keyword argument instead. 3614 3615 3616 3617 Features 3618 -------- 3619 3620 - :issue:`1682`: The ``scope`` parameter of ``@pytest.fixture`` can now be a callable that receives 3621 the fixture name and the ``config`` object as keyword-only parameters. 3622 See :ref:`the docs <dynamic scope>` for more information. 3623 3624 3625 - :issue:`5764`: New behavior of the ``--pastebin`` option: failures to connect to the pastebin server are reported, without failing the pytest run 3626 3627 3628 3629 Bug Fixes 3630 --------- 3631 3632 - :issue:`5806`: Fix "lexer" being used when uploading to bpaste.net from ``--pastebin`` to "text". 3633 3634 3635 - :issue:`5884`: Fix ``--setup-only`` and ``--setup-show`` for custom pytest items. 3636 3637 3638 3639 Trivial/Internal Changes 3640 ------------------------ 3641 3642 - :issue:`5056`: The HelpFormatter uses ``py.io.get_terminal_width`` for better width detection. 3643 3644 3645 pytest 5.1.3 (2019-09-18) 3646 ========================= 3647 3648 Bug Fixes 3649 --------- 3650 3651 - :issue:`5807`: Fix pypy3.6 (nightly) on windows. 3652 3653 3654 - :issue:`5811`: Handle ``--fulltrace`` correctly with ``pytest.raises``. 3655 3656 3657 - :issue:`5819`: Windows: Fix regression with conftest whose qualified name contains uppercase 3658 characters (introduced by #5792). 3659 3660 3661 pytest 5.1.2 (2019-08-30) 3662 ========================= 3663 3664 Bug Fixes 3665 --------- 3666 3667 - :issue:`2270`: Fixed ``self`` reference in function-scoped fixtures defined plugin classes: previously ``self`` 3668 would be a reference to a *test* class, not the *plugin* class. 3669 3670 3671 - :issue:`570`: Fixed long standing issue where fixture scope was not respected when indirect fixtures were used during 3672 parametrization. 3673 3674 3675 - :issue:`5782`: Fix decoding error when printing an error response from ``--pastebin``. 3676 3677 3678 - :issue:`5786`: Chained exceptions in test and collection reports are now correctly serialized, allowing plugins like 3679 ``pytest-xdist`` to display them properly. 3680 3681 3682 - :issue:`5792`: Windows: Fix error that occurs in certain circumstances when loading 3683 ``conftest.py`` from a working directory that has casing other than the one stored 3684 in the filesystem (e.g., ``c:\test`` instead of ``C:\test``). 3685 3686 3687 pytest 5.1.1 (2019-08-20) 3688 ========================= 3689 3690 Bug Fixes 3691 --------- 3692 3693 - :issue:`5751`: Fixed ``TypeError`` when importing pytest on Python 3.5.0 and 3.5.1. 3694 3695 3696 pytest 5.1.0 (2019-08-15) 3697 ========================= 3698 3699 Removals 3700 -------- 3701 3702 - :issue:`5180`: As per our policy, the following features have been deprecated in the 4.X series and are now 3703 removed: 3704 3705 * ``Request.getfuncargvalue``: use ``Request.getfixturevalue`` instead. 3706 3707 * ``pytest.raises`` and ``pytest.warns`` no longer support strings as the second argument. 3708 3709 * ``message`` parameter of ``pytest.raises``. 3710 3711 * ``pytest.raises``, ``pytest.warns`` and ``ParameterSet.param`` now use native keyword-only 3712 syntax. This might change the exception message from previous versions, but they still raise 3713 ``TypeError`` on unknown keyword arguments as before. 3714 3715 * ``pytest.config`` global variable. 3716 3717 * ``tmpdir_factory.ensuretemp`` method. 3718 3719 * ``pytest_logwarning`` hook. 3720 3721 * ``RemovedInPytest4Warning`` warning type. 3722 3723 * ``request`` is now a reserved name for fixtures. 3724 3725 3726 For more information consult :std:doc:`deprecations` in the docs. 3727 3728 3729 - :issue:`5565`: Removed unused support code for :pypi:`unittest2`. 3730 3731 The ``unittest2`` backport module is no longer 3732 necessary since Python 3.3+, and the small amount of code in pytest to support it also doesn't seem 3733 to be used: after removed, all tests still pass unchanged. 3734 3735 Although our policy is to introduce a deprecation period before removing any features or support 3736 for third party libraries, because this code is apparently not used 3737 at all (even if ``unittest2`` is used by a test suite executed by pytest), it was decided to 3738 remove it in this release. 3739 3740 If you experience a regression because of this, please :issue:`file an issue <new>`. 3741 3742 3743 - :issue:`5615`: ``pytest.fail``, ``pytest.xfail`` and ``pytest.skip`` no longer support bytes for the message argument. 3744 3745 This was supported for Python 2 where it was tempting to use ``"message"`` 3746 instead of ``u"message"``. 3747 3748 Python 3 code is unlikely to pass ``bytes`` to these functions. If you do, 3749 please decode it to an ``str`` beforehand. 3750 3751 3752 3753 Features 3754 -------- 3755 3756 - :issue:`5564`: New ``Config.invocation_args`` attribute containing the unchanged arguments passed to ``pytest.main()``. 3757 3758 3759 - :issue:`5576`: New :ref:`NUMBER <using doctest options>` 3760 option for doctests to ignore irrelevant differences in floating-point numbers. 3761 Inspired by Sébastien Boisgérault's `numtest <https://github.com/boisgera/numtest>`__ 3762 extension for doctest. 3763 3764 3765 3766 Improvements 3767 ------------ 3768 3769 - :issue:`5471`: JUnit XML now includes a timestamp and hostname in the testsuite tag. 3770 3771 3772 - :issue:`5707`: Time taken to run the test suite now includes a human-readable representation when it takes over 3773 60 seconds, for example:: 3774 3775 ===== 2 failed in 102.70s (0:01:42) ===== 3776 3777 3778 3779 Bug Fixes 3780 --------- 3781 3782 - :issue:`4344`: Fix RuntimeError/StopIteration when trying to collect package with "__init__.py" only. 3783 3784 3785 - :issue:`5115`: Warnings issued during ``pytest_configure`` are explicitly not treated as errors, even if configured as such, because it otherwise completely breaks pytest. 3786 3787 3788 - :issue:`5477`: The XML file produced by ``--junitxml`` now correctly contain a ``<testsuites>`` root element. 3789 3790 3791 - :issue:`5524`: Fix issue where ``tmp_path`` and ``tmpdir`` would not remove directories containing files marked as read-only, 3792 which could lead to pytest crashing when executed a second time with the ``--basetemp`` option. 3793 3794 3795 - :issue:`5537`: Replace ``importlib_metadata`` backport with ``importlib.metadata`` from the 3796 standard library on Python 3.8+. 3797 3798 3799 - :issue:`5578`: Improve type checking for some exception-raising functions (``pytest.xfail``, ``pytest.skip``, etc) 3800 so they provide better error messages when users meant to use marks (for example ``@pytest.xfail`` 3801 instead of ``@pytest.mark.xfail``). 3802 3803 3804 - :issue:`5606`: Fixed internal error when test functions were patched with objects that cannot be compared 3805 for truth values against others, like ``numpy`` arrays. 3806 3807 3808 - :issue:`5634`: ``pytest.exit`` is now correctly handled in ``unittest`` cases. 3809 This makes ``unittest`` cases handle ``quit`` from pytest's pdb correctly. 3810 3811 3812 - :issue:`5650`: Improved output when parsing an ini configuration file fails. 3813 3814 3815 - :issue:`5701`: Fix collection of ``staticmethod`` objects defined with ``functools.partial``. 3816 3817 3818 - :issue:`5734`: Skip async generator test functions, and update the warning message to refer to ``async def`` functions. 3819 3820 3821 3822 Improved Documentation 3823 ---------------------- 3824 3825 - :issue:`5669`: Add docstring for ``Testdir.copy_example``. 3826 3827 3828 3829 Trivial/Internal Changes 3830 ------------------------ 3831 3832 - :issue:`5095`: XML files of the ``xunit2`` family are now validated against the schema by pytest's own test suite 3833 to avoid future regressions. 3834 3835 3836 - :issue:`5516`: Cache node splitting function which can improve collection performance in very large test suites. 3837 3838 3839 - :issue:`5603`: Simplified internal ``SafeRepr`` class and removed some dead code. 3840 3841 3842 - :issue:`5664`: When invoking pytest's own testsuite with ``PYTHONDONTWRITEBYTECODE=1``, 3843 the ``test_xfail_handling`` test no longer fails. 3844 3845 3846 - :issue:`5684`: Replace manual handling of ``OSError.errno`` in the codebase by new ``OSError`` subclasses (``PermissionError``, ``FileNotFoundError``, etc.). 3847 3848 3849 pytest 5.0.1 (2019-07-04) 3850 ========================= 3851 3852 Bug Fixes 3853 --------- 3854 3855 - :issue:`5479`: Improve quoting in ``raises`` match failure message. 3856 3857 3858 - :issue:`5523`: Fixed using multiple short options together in the command-line (for example ``-vs``) in Python 3.8+. 3859 3860 3861 - :issue:`5547`: ``--step-wise`` now handles ``xfail(strict=True)`` markers properly. 3862 3863 3864 3865 Improved Documentation 3866 ---------------------- 3867 3868 - :issue:`5517`: Improve "Declaring new hooks" section in chapter "Writing Plugins" 3869 3870 3871 pytest 5.0.0 (2019-06-28) 3872 ========================= 3873 3874 Important 3875 --------- 3876 3877 This release is a Python3.5+ only release. 3878 3879 For more details, see our `Python 2.7 and 3.4 support plan 3880 <https://docs.pytest.org/en/7.0.x/py27-py34-deprecation.html>`_. 3881 3882 Removals 3883 -------- 3884 3885 - :issue:`1149`: Pytest no longer accepts prefixes of command-line arguments, for example 3886 typing ``pytest --doctest-mod`` inplace of ``--doctest-modules``. 3887 This was previously allowed where the ``ArgumentParser`` thought it was unambiguous, 3888 but this could be incorrect due to delayed parsing of options for plugins. 3889 See for example issues :issue:`1149`, 3890 :issue:`3413`, and 3891 :issue:`4009`. 3892 3893 3894 - :issue:`5402`: **PytestDeprecationWarning are now errors by default.** 3895 3896 Following our plan to remove deprecated features with as little disruption as 3897 possible, all warnings of type ``PytestDeprecationWarning`` now generate errors 3898 instead of warning messages. 3899 3900 **The affected features will be effectively removed in pytest 5.1**, so please consult the 3901 :std:doc:`deprecations` section in the docs for directions on how to update existing code. 3902 3903 In the pytest ``5.0.X`` series, it is possible to change the errors back into warnings as a stop 3904 gap measure by adding this to your ``pytest.ini`` file: 3905 3906 .. code-block:: ini 3907 3908 [pytest] 3909 filterwarnings = 3910 ignore::pytest.PytestDeprecationWarning 3911 3912 But this will stop working when pytest ``5.1`` is released. 3913 3914 **If you have concerns** about the removal of a specific feature, please add a 3915 comment to :issue:`5402`. 3916 3917 3918 - :issue:`5412`: ``ExceptionInfo`` objects (returned by ``pytest.raises``) now have the same ``str`` representation as ``repr``, which 3919 avoids some confusion when users use ``print(e)`` to inspect the object. 3920 3921 This means code like: 3922 3923 .. code-block:: python 3924 3925 with pytest.raises(SomeException) as e: 3926 ... 3927 assert "some message" in str(e) 3928 3929 3930 Needs to be changed to: 3931 3932 .. code-block:: python 3933 3934 with pytest.raises(SomeException) as e: 3935 ... 3936 assert "some message" in str(e.value) 3937 3938 3939 3940 3941 Deprecations 3942 ------------ 3943 3944 - :issue:`4488`: The removal of the ``--result-log`` option and module has been postponed to (tentatively) pytest 6.0 as 3945 the team has not yet got around to implement a good alternative for it. 3946 3947 3948 - :issue:`466`: The ``funcargnames`` attribute has been an alias for ``fixturenames`` since 3949 pytest 2.3, and is now deprecated in code too. 3950 3951 3952 3953 Features 3954 -------- 3955 3956 - :issue:`3457`: New :hook:`pytest_assertion_pass` 3957 hook, called with context information when an assertion *passes*. 3958 3959 This hook is still **experimental** so use it with caution. 3960 3961 3962 - :issue:`5440`: The :mod:`faulthandler` standard library 3963 module is now enabled by default to help users diagnose crashes in C modules. 3964 3965 This functionality was provided by integrating the external 3966 `pytest-faulthandler <https://github.com/pytest-dev/pytest-faulthandler>`__ plugin into the core, 3967 so users should remove that plugin from their requirements if used. 3968 3969 For more information see the docs: :ref:`faulthandler`. 3970 3971 3972 - :issue:`5452`: When warnings are configured as errors, pytest warnings now appear as originating from ``pytest.`` instead of the internal ``_pytest.warning_types.`` module. 3973 3974 3975 - :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. 3976 3977 The team doesn't expect this change to break test suites or plugins in general, except in esoteric/specific scenarios. 3978 3979 **pytest-xdist** users should upgrade to ``1.29.0`` or later, as ``pytest-xdist`` required a compatibility fix because of this change. 3980 3981 3982 3983 Bug Fixes 3984 --------- 3985 3986 - :issue:`1403`: Switch from ``imp`` to ``importlib``. 3987 3988 3989 - :issue:`1671`: The name of the ``.pyc`` files cached by the assertion writer now includes the pytest version 3990 to avoid stale caches. 3991 3992 3993 - :issue:`2761`: Honor :pep:`235` on case-insensitive file systems. 3994 3995 3996 - :issue:`5078`: Test module is no longer double-imported when using ``--pyargs``. 3997 3998 3999 - :issue:`5260`: Improved comparison of byte strings. 4000 4001 When comparing bytes, the assertion message used to show the byte numeric value when showing the differences:: 4002 4003 def test(): 4004 > assert b'spam' == b'eggs' 4005 E AssertionError: assert b'spam' == b'eggs' 4006 E At index 0 diff: 115 != 101 4007 E Use -v to get the full diff 4008 4009 It now shows the actual ascii representation instead, which is often more useful:: 4010 4011 def test(): 4012 > assert b'spam' == b'eggs' 4013 E AssertionError: assert b'spam' == b'eggs' 4014 E At index 0 diff: b's' != b'e' 4015 E Use -v to get the full diff 4016 4017 4018 - :issue:`5335`: Colorize level names when the level in the logging format is formatted using 4019 '%(levelname).Xs' (truncated fixed width alignment), where X is an integer. 4020 4021 4022 - :issue:`5354`: Fix ``pytest.mark.parametrize`` when the argvalues is an iterator. 4023 4024 4025 - :issue:`5370`: Revert unrolling of ``all()`` to fix ``NameError`` on nested comprehensions. 4026 4027 4028 - :issue:`5371`: Revert unrolling of ``all()`` to fix incorrect handling of generators with ``if``. 4029 4030 4031 - :issue:`5372`: Revert unrolling of ``all()`` to fix incorrect assertion when using ``all()`` in an expression. 4032 4033 4034 - :issue:`5383`: ``-q`` has again an impact on the style of the collected items 4035 (``--collect-only``) when ``--log-cli-level`` is used. 4036 4037 4038 - :issue:`5389`: Fix regressions of :pull:`5063` for ``importlib_metadata.PathDistribution`` which have their ``files`` attribute being ``None``. 4039 4040 4041 - :issue:`5390`: Fix regression where the ``obj`` attribute of ``TestCase`` items was no longer bound to methods. 4042 4043 4044 - :issue:`5404`: Emit a warning when attempting to unwrap a broken object raises an exception, 4045 for easier debugging (:issue:`5080`). 4046 4047 4048 - :issue:`5432`: Prevent "already imported" warnings from assertion rewriter when invoking pytest in-process multiple times. 4049 4050 4051 - :issue:`5433`: Fix assertion rewriting in packages (``__init__.py``). 4052 4053 4054 - :issue:`5444`: Fix ``--stepwise`` mode when the first file passed on the command-line fails to collect. 4055 4056 4057 - :issue:`5482`: Fix bug introduced in 4.6.0 causing collection errors when passing 4058 more than 2 positional arguments to ``pytest.mark.parametrize``. 4059 4060 4061 - :issue:`5505`: Fix crash when discovery fails while using ``-p no:terminal``. 4062 4063 4064 4065 Improved Documentation 4066 ---------------------- 4067 4068 - :issue:`5315`: Expand docs on mocking classes and dictionaries with ``monkeypatch``. 4069 4070 4071 - :issue:`5416`: Fix PytestUnknownMarkWarning in run/skip example. 4072 4073 4074 pytest 4.6.11 (2020-06-04) 4075 ========================== 4076 4077 Bug Fixes 4078 --------- 4079 4080 - :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``). 4081 4082 The upper case variants were never documented and the preferred form should be the lower case. 4083 4084 4085 - :issue:`7310`: Fix ``UnboundLocalError: local variable 'letter' referenced before 4086 assignment`` in ``_pytest.terminal.pytest_report_teststatus()`` 4087 when plugins return report objects in an unconventional state. 4088 4089 This was making ``pytest_report_teststatus()`` skip 4090 entering if-block branches that declare the ``letter`` variable. 4091 4092 The fix was to set the initial value of the ``letter`` before 4093 the if-block cascade so that it always has a value. 4094 4095 4096 pytest 4.6.10 (2020-05-08) 4097 ========================== 4098 4099 Features 4100 -------- 4101 4102 - :issue:`6870`: New ``Config.invocation_args`` attribute containing the unchanged arguments passed to ``pytest.main()``. 4103 4104 Remark: while this is technically a new feature and according to our 4105 `policy <https://docs.pytest.org/en/7.0.x/py27-py34-deprecation.html#what-goes-into-4-6-x-releases>`_ 4106 it should not have been backported, we have opened an exception in this 4107 particular case because it fixes a serious interaction with ``pytest-xdist``, 4108 so it can also be considered a bugfix. 4109 4110 Trivial/Internal Changes 4111 ------------------------ 4112 4113 - :issue:`6404`: Remove usage of ``parser`` module, deprecated in Python 3.9. 4114 4115 4116 pytest 4.6.9 (2020-01-04) 4117 ========================= 4118 4119 Bug Fixes 4120 --------- 4121 4122 - :issue:`6301`: Fix assertion rewriting for egg-based distributions and ``editable`` installs (``pip install --editable``). 4123 4124 4125 pytest 4.6.8 (2019-12-19) 4126 ========================= 4127 4128 Features 4129 -------- 4130 4131 - :issue:`5471`: JUnit XML now includes a timestamp and hostname in the testsuite tag. 4132 4133 4134 4135 Bug Fixes 4136 --------- 4137 4138 - :issue:`5430`: junitxml: Logs for failed test are now passed to junit report in case the test fails during call phase. 4139 4140 4141 4142 Trivial/Internal Changes 4143 ------------------------ 4144 4145 - :issue:`6345`: Pin ``colorama`` to ``0.4.1`` only for Python 3.4 so newer Python versions can still receive colorama updates. 4146 4147 4148 pytest 4.6.7 (2019-12-05) 4149 ========================= 4150 4151 Bug Fixes 4152 --------- 4153 4154 - :issue:`5477`: The XML file produced by ``--junitxml`` now correctly contain a ``<testsuites>`` root element. 4155 4156 4157 - :issue:`6044`: Properly ignore ``FileNotFoundError`` (``OSError.errno == NOENT`` in Python 2) exceptions when trying to remove old temporary directories, 4158 for instance when multiple processes try to remove the same directory (common with ``pytest-xdist`` 4159 for example). 4160 4161 4162 pytest 4.6.6 (2019-10-11) 4163 ========================= 4164 4165 Bug Fixes 4166 --------- 4167 4168 - :issue:`5523`: Fixed using multiple short options together in the command-line (for example ``-vs``) in Python 3.8+. 4169 4170 4171 - :issue:`5537`: Replace ``importlib_metadata`` backport with ``importlib.metadata`` from the 4172 standard library on Python 3.8+. 4173 4174 4175 - :issue:`5806`: Fix "lexer" being used when uploading to bpaste.net from ``--pastebin`` to "text". 4176 4177 4178 - :issue:`5902`: Fix warnings about deprecated ``cmp`` attribute in ``attrs>=19.2``. 4179 4180 4181 4182 Trivial/Internal Changes 4183 ------------------------ 4184 4185 - :issue:`5801`: Fixes python version checks (detected by ``flake8-2020``) in case python4 becomes a thing. 4186 4187 4188 pytest 4.6.5 (2019-08-05) 4189 ========================= 4190 4191 Bug Fixes 4192 --------- 4193 4194 - :issue:`4344`: Fix RuntimeError/StopIteration when trying to collect package with "__init__.py" only. 4195 4196 4197 - :issue:`5478`: Fix encode error when using unicode strings in exceptions with ``pytest.raises``. 4198 4199 4200 - :issue:`5524`: Fix issue where ``tmp_path`` and ``tmpdir`` would not remove directories containing files marked as read-only, 4201 which could lead to pytest crashing when executed a second time with the ``--basetemp`` option. 4202 4203 4204 - :issue:`5547`: ``--step-wise`` now handles ``xfail(strict=True)`` markers properly. 4205 4206 4207 - :issue:`5650`: Improved output when parsing an ini configuration file fails. 4208 4209 pytest 4.6.4 (2019-06-28) 4210 ========================= 4211 4212 Bug Fixes 4213 --------- 4214 4215 - :issue:`5404`: Emit a warning when attempting to unwrap a broken object raises an exception, 4216 for easier debugging (:issue:`5080`). 4217 4218 4219 - :issue:`5444`: Fix ``--stepwise`` mode when the first file passed on the command-line fails to collect. 4220 4221 4222 - :issue:`5482`: Fix bug introduced in 4.6.0 causing collection errors when passing 4223 more than 2 positional arguments to ``pytest.mark.parametrize``. 4224 4225 4226 - :issue:`5505`: Fix crash when discovery fails while using ``-p no:terminal``. 4227 4228 4229 pytest 4.6.3 (2019-06-11) 4230 ========================= 4231 4232 Bug Fixes 4233 --------- 4234 4235 - :issue:`5383`: ``-q`` has again an impact on the style of the collected items 4236 (``--collect-only``) when ``--log-cli-level`` is used. 4237 4238 4239 - :issue:`5389`: Fix regressions of :pull:`5063` for ``importlib_metadata.PathDistribution`` which have their ``files`` attribute being ``None``. 4240 4241 4242 - :issue:`5390`: Fix regression where the ``obj`` attribute of ``TestCase`` items was no longer bound to methods. 4243 4244 4245 pytest 4.6.2 (2019-06-03) 4246 ========================= 4247 4248 Bug Fixes 4249 --------- 4250 4251 - :issue:`5370`: Revert unrolling of ``all()`` to fix ``NameError`` on nested comprehensions. 4252 4253 4254 - :issue:`5371`: Revert unrolling of ``all()`` to fix incorrect handling of generators with ``if``. 4255 4256 4257 - :issue:`5372`: Revert unrolling of ``all()`` to fix incorrect assertion when using ``all()`` in an expression. 4258 4259 4260 pytest 4.6.1 (2019-06-02) 4261 ========================= 4262 4263 Bug Fixes 4264 --------- 4265 4266 - :issue:`5354`: Fix ``pytest.mark.parametrize`` when the argvalues is an iterator. 4267 4268 4269 - :issue:`5358`: Fix assertion rewriting of ``all()`` calls to deal with non-generators. 4270 4271 4272 pytest 4.6.0 (2019-05-31) 4273 ========================= 4274 4275 Important 4276 --------- 4277 4278 The ``4.6.X`` series will be the last series to support **Python 2 and Python 3.4**. 4279 4280 For more details, see our `Python 2.7 and 3.4 support plan 4281 <https://docs.pytest.org/en/7.0.x/py27-py34-deprecation.html>`_. 4282 4283 4284 Features 4285 -------- 4286 4287 - :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. 4288 4289 4290 - :issue:`4956`: pytester's ``testdir.spawn`` uses ``tmpdir`` as HOME/USERPROFILE directory. 4291 4292 4293 - :issue:`5062`: Unroll calls to ``all`` to full for-loops with assertion rewriting for better failure messages, especially when using Generator Expressions. 4294 4295 4296 - :issue:`5063`: Switch from ``pkg_resources`` to ``importlib-metadata`` for entrypoint detection for improved performance and import time. 4297 4298 4299 - :issue:`5091`: The output for ini options in ``--help`` has been improved. 4300 4301 4302 - :issue:`5269`: ``pytest.importorskip`` includes the ``ImportError`` now in the default ``reason``. 4303 4304 4305 - :issue:`5311`: Captured logs that are output for each failing test are formatted using the 4306 ColoredLevelFormatter. 4307 4308 4309 - :issue:`5312`: Improved formatting of multiline log messages in Python 3. 4310 4311 4312 4313 Bug Fixes 4314 --------- 4315 4316 - :issue:`2064`: The debugging plugin imports the wrapped ``Pdb`` class (``--pdbcls``) on-demand now. 4317 4318 4319 - :issue:`4908`: The ``pytest_enter_pdb`` hook gets called with post-mortem (``--pdb``). 4320 4321 4322 - :issue:`5036`: Fix issue where fixtures dependent on other parametrized fixtures would be erroneously parametrized. 4323 4324 4325 - :issue:`5256`: Handle internal error due to a lone surrogate unicode character not being representable in Jython. 4326 4327 4328 - :issue:`5257`: Ensure that ``sys.stdout.mode`` does not include ``'b'`` as it is a text stream. 4329 4330 4331 - :issue:`5278`: Pytest's internal python plugin can be disabled using ``-p no:python`` again. 4332 4333 4334 - :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. 4335 4336 4337 - :issue:`5330`: Show the test module being collected when emitting ``PytestCollectionWarning`` messages for 4338 test classes with ``__init__`` and ``__new__`` methods to make it easier to pin down the problem. 4339 4340 4341 - :issue:`5333`: Fix regression in 4.5.0 with ``--lf`` not re-running all tests with known failures from non-selected tests. 4342 4343 4344 4345 Improved Documentation 4346 ---------------------- 4347 4348 - :issue:`5250`: Expand docs on use of ``setenv`` and ``delenv`` with ``monkeypatch``. 4349 4350 4351 pytest 4.5.0 (2019-05-11) 4352 ========================= 4353 4354 Features 4355 -------- 4356 4357 - :issue:`4826`: A warning is now emitted when unknown marks are used as a decorator. 4358 This is often due to a typo, which can lead to silently broken tests. 4359 4360 4361 - :issue:`4907`: Show XFail reason as part of JUnitXML message field. 4362 4363 4364 - :issue:`5013`: Messages from crash reports are displayed within test summaries now, truncated to the terminal width. 4365 4366 4367 - :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. 4368 4369 The existing ``--strict`` option has the same behavior currently, but can be augmented in the future for additional checks. 4370 4371 4372 - :issue:`5026`: Assertion failure messages for sequences and dicts contain the number of different items now. 4373 4374 4375 - :issue:`5034`: Improve reporting with ``--lf`` and ``--ff`` (run-last-failure). 4376 4377 4378 - :issue:`5035`: The ``--cache-show`` option/action accepts an optional glob to show only matching cache entries. 4379 4380 4381 - :issue:`5059`: Standard input (stdin) can be given to pytester's ``Testdir.run()`` and ``Testdir.popen()``. 4382 4383 4384 - :issue:`5068`: The ``-r`` option learnt about ``A`` to display all reports (including passed ones) in the short test summary. 4385 4386 4387 - :issue:`5108`: The short test summary is displayed after passes with output (``-rP``). 4388 4389 4390 - :issue:`5172`: The ``--last-failed`` (``--lf``) option got smarter and will now skip entire files if all tests 4391 of that test file have passed in previous runs, greatly speeding up collection. 4392 4393 4394 - :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: 4395 4396 4397 * ``PytestAssertRewriteWarning`` 4398 4399 * ``PytestCacheWarning`` 4400 4401 * ``PytestCollectionWarning`` 4402 4403 * ``PytestConfigWarning`` 4404 4405 * ``PytestUnhandledCoroutineWarning`` 4406 4407 * ``PytestUnknownMarkWarning`` 4408 4409 4410 - :issue:`5202`: New ``record_testsuite_property`` session-scoped fixture allows users to log ``<property>`` tags at the ``testsuite`` 4411 level with the ``junitxml`` plugin. 4412 4413 The generated XML is compatible with the latest xunit standard, contrary to 4414 the properties recorded by ``record_property`` and ``record_xml_attribute``. 4415 4416 4417 - :issue:`5214`: The default logging format has been changed to improve readability. Here is an 4418 example of a previous logging message:: 4419 4420 test_log_cli_enabled_disabled.py 3 CRITICAL critical message logged by test 4421 4422 This has now become:: 4423 4424 CRITICAL root:test_log_cli_enabled_disabled.py:3 critical message logged by test 4425 4426 The formatting can be changed through the :confval:`log_format` configuration option. 4427 4428 4429 - :issue:`5220`: ``--fixtures`` now also shows fixture scope for scopes other than ``"function"``. 4430 4431 4432 4433 Bug Fixes 4434 --------- 4435 4436 - :issue:`5113`: Deselected items from plugins using ``pytest_collect_modifyitems`` as a hookwrapper are correctly reported now. 4437 4438 4439 - :issue:`5144`: With usage errors ``exitstatus`` is set to ``EXIT_USAGEERROR`` in the ``pytest_sessionfinish`` hook now as expected. 4440 4441 4442 - :issue:`5235`: ``outcome.exit`` is not used with ``EOF`` in the pdb wrapper anymore, but only with ``quit``. 4443 4444 4445 4446 Improved Documentation 4447 ---------------------- 4448 4449 - :issue:`4935`: Expand docs on registering marks and the effect of ``--strict``. 4450 4451 4452 4453 Trivial/Internal Changes 4454 ------------------------ 4455 4456 - :issue:`4942`: ``logging.raiseExceptions`` is not set to ``False`` anymore. 4457 4458 4459 - :issue:`5013`: pytest now depends on :pypi:`wcwidth` to properly track unicode character sizes for more precise terminal output. 4460 4461 4462 - :issue:`5059`: pytester's ``Testdir.popen()`` uses ``stdout`` and ``stderr`` via keyword arguments with defaults now (``subprocess.PIPE``). 4463 4464 4465 - :issue:`5069`: The code for the short test summary in the terminal was moved to the terminal plugin. 4466 4467 4468 - :issue:`5082`: Improved validation of kwargs for various methods in the pytester plugin. 4469 4470 4471 - :issue:`5202`: ``record_property`` now emits a ``PytestWarning`` when used with ``junit_family=xunit2``: the fixture generates 4472 ``property`` tags as children of ``testcase``, which is not permitted according to the most 4473 `recent schema <https://github.com/jenkinsci/xunit-plugin/blob/master/ 4474 src/main/resources/org/jenkinsci/plugins/xunit/types/model/xsd/junit-10.xsd>`__. 4475 4476 4477 - :issue:`5239`: Pin ``pluggy`` to ``< 1.0`` so we don't update to ``1.0`` automatically when 4478 it gets released: there are planned breaking changes, and we want to ensure 4479 pytest properly supports ``pluggy 1.0``. 4480 4481 4482 pytest 4.4.2 (2019-05-08) 4483 ========================= 4484 4485 Bug Fixes 4486 --------- 4487 4488 - :issue:`5089`: Fix crash caused by error in ``__repr__`` function with both ``showlocals`` and verbose output enabled. 4489 4490 4491 - :issue:`5139`: Eliminate core dependency on 'terminal' plugin. 4492 4493 4494 - :issue:`5229`: Require ``pluggy>=0.11.0`` which reverts a dependency to ``importlib-metadata`` added in ``0.10.0``. 4495 The ``importlib-metadata`` package cannot be imported when installed as an egg and causes issues when relying on ``setup.py`` to install test dependencies. 4496 4497 4498 4499 Improved Documentation 4500 ---------------------- 4501 4502 - :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`` 4503 4504 4505 - :issue:`5188`: Improve help for ``--runxfail`` flag. 4506 4507 4508 4509 Trivial/Internal Changes 4510 ------------------------ 4511 4512 - :issue:`5182`: Removed internal and unused ``_pytest.deprecated.MARK_INFO_ATTRIBUTE``. 4513 4514 4515 pytest 4.4.1 (2019-04-15) 4516 ========================= 4517 4518 Bug Fixes 4519 --------- 4520 4521 - :issue:`5031`: Environment variables are properly restored when using pytester's ``testdir`` fixture. 4522 4523 4524 - :issue:`5039`: Fix regression with ``--pdbcls``, which stopped working with local modules in 4.0.0. 4525 4526 4527 - :issue:`5092`: Produce a warning when unknown keywords are passed to ``pytest.param(...)``. 4528 4529 4530 - :issue:`5098`: Invalidate import caches with ``monkeypatch.syspath_prepend``, which is required with namespace packages being used. 4531 4532 4533 pytest 4.4.0 (2019-03-29) 4534 ========================= 4535 4536 Features 4537 -------- 4538 4539 - :issue:`2224`: ``async`` test functions are skipped and a warning is emitted when a suitable 4540 async plugin is not installed (such as ``pytest-asyncio`` or ``pytest-trio``). 4541 4542 Previously ``async`` functions would not execute at all but still be marked as "passed". 4543 4544 4545 - :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. 4546 4547 4548 - :issue:`4718`: The ``-p`` option can now be used to early-load plugins also by entry-point name, instead of just 4549 by module name. 4550 4551 This makes it possible to early load external plugins like ``pytest-cov`` in the command-line:: 4552 4553 pytest -p pytest_cov 4554 4555 4556 - :issue:`4855`: The ``--pdbcls`` option handles classes via module attributes now (e.g. 4557 ``pdb:pdb.Pdb`` with :pypi:`pdbpp`), and its validation was improved. 4558 4559 4560 - :issue:`4875`: The :confval:`testpaths` configuration option is now displayed next 4561 to the ``rootdir`` and ``inifile`` lines in the pytest header if the option is in effect, i.e., directories or file names were 4562 not explicitly passed in the command line. 4563 4564 Also, ``inifile`` is only displayed if there's a configuration file, instead of an empty ``inifile:`` string. 4565 4566 4567 - :issue:`4911`: Doctests can be skipped now dynamically using ``pytest.skip()``. 4568 4569 4570 - :issue:`4920`: Internal refactorings have been made in order to make the implementation of the 4571 `pytest-subtests <https://github.com/pytest-dev/pytest-subtests>`__ plugin 4572 possible, which adds unittest sub-test support and a new ``subtests`` fixture as discussed in 4573 :issue:`1367`. 4574 4575 For details on the internal refactorings, please see the details on the related PR. 4576 4577 4578 - :issue:`4931`: pytester's ``LineMatcher`` asserts that the passed lines are a sequence. 4579 4580 4581 - :issue:`4936`: Handle ``-p plug`` after ``-p no:plug``. 4582 4583 This can be used to override a blocked plugin (e.g. in "addopts") from the 4584 command line etc. 4585 4586 4587 - :issue:`4951`: Output capturing is handled correctly when only capturing via fixtures (capsys, capfs) with ``pdb.set_trace()``. 4588 4589 4590 - :issue:`4956`: ``pytester`` sets ``$HOME`` and ``$USERPROFILE`` to the temporary directory during test runs. 4591 4592 This ensures to not load configuration files from the real user's home directory. 4593 4594 4595 - :issue:`4980`: Namespace packages are handled better with ``monkeypatch.syspath_prepend`` and ``testdir.syspathinsert`` (via ``pkg_resources.fixup_namespace_packages``). 4596 4597 4598 - :issue:`4993`: The stepwise plugin reports status information now. 4599 4600 4601 - :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. 4602 4603 This makes it simpler for plugins to support old pytest versions. 4604 4605 4606 4607 Bug Fixes 4608 --------- 4609 4610 - :issue:`1895`: Fix bug where fixtures requested dynamically via ``request.getfixturevalue()`` might be teardown 4611 before the requesting fixture. 4612 4613 4614 - :issue:`4851`: pytester unsets ``PYTEST_ADDOPTS`` now to not use outer options with ``testdir.runpytest()``. 4615 4616 4617 - :issue:`4903`: Use the correct modified time for years after 2038 in rewritten ``.pyc`` files. 4618 4619 4620 - :issue:`4928`: Fix line offsets with ``ScopeMismatch`` errors. 4621 4622 4623 - :issue:`4957`: ``-p no:plugin`` is handled correctly for default (internal) plugins now, e.g. with ``-p no:capture``. 4624 4625 Previously they were loaded (imported) always, making e.g. the ``capfd`` fixture available. 4626 4627 4628 - :issue:`4968`: The pdb ``quit`` command is handled properly when used after the ``debug`` command with :pypi:`pdbpp`. 4629 4630 4631 - :issue:`4975`: Fix the interpretation of ``-qq`` option where it was being considered as ``-v`` instead. 4632 4633 4634 - :issue:`4978`: ``outcomes.Exit`` is not swallowed in ``assertrepr_compare`` anymore. 4635 4636 4637 - :issue:`4988`: Close logging's file handler explicitly when the session finishes. 4638 4639 4640 - :issue:`5003`: Fix line offset with mark collection error (off by one). 4641 4642 4643 4644 Improved Documentation 4645 ---------------------- 4646 4647 - :issue:`4974`: Update docs for ``pytest_cmdline_parse`` hook to note availability limitations 4648 4649 4650 4651 Trivial/Internal Changes 4652 ------------------------ 4653 4654 - :issue:`4718`: ``pluggy>=0.9`` is now required. 4655 4656 4657 - :issue:`4815`: ``funcsigs>=1.0`` is now required for Python 2.7. 4658 4659 4660 - :issue:`4829`: Some left-over internal code related to ``yield`` tests has been removed. 4661 4662 4663 - :issue:`4890`: Remove internally unused ``anypython`` fixture from the pytester plugin. 4664 4665 4666 - :issue:`4912`: Remove deprecated Sphinx directive, ``add_description_unit()``, 4667 pin sphinx-removed-in to >= 0.2.0 to support Sphinx 2.0. 4668 4669 4670 - :issue:`4913`: Fix pytest tests invocation with custom ``PYTHONPATH``. 4671 4672 4673 - :issue:`4965`: New ``pytest_report_to_serializable`` and ``pytest_report_from_serializable`` **experimental** hooks. 4674 4675 These hooks will be used by ``pytest-xdist``, ``pytest-subtests``, and the replacement for 4676 resultlog to serialize and customize reports. 4677 4678 They are experimental, meaning that their details might change or even be removed 4679 completely in future patch releases without warning. 4680 4681 Feedback is welcome from plugin authors and users alike. 4682 4683 4684 - :issue:`4987`: ``Collector.repr_failure`` respects the ``--tb`` option, but only defaults to ``short`` now (with ``auto``). 4685 4686 4687 pytest 4.3.1 (2019-03-11) 4688 ========================= 4689 4690 Bug Fixes 4691 --------- 4692 4693 - :issue:`4810`: Logging messages inside ``pytest_runtest_logreport()`` are now properly captured and displayed. 4694 4695 4696 - :issue:`4861`: Improve validation of contents written to captured output so it behaves the same as when capture is disabled. 4697 4698 4699 - :issue:`4898`: Fix ``AttributeError: FixtureRequest has no 'confg' attribute`` bug in ``testdir.copy_example``. 4700 4701 4702 4703 Trivial/Internal Changes 4704 ------------------------ 4705 4706 - :issue:`4768`: Avoid pkg_resources import at the top-level. 4707 4708 4709 pytest 4.3.0 (2019-02-16) 4710 ========================= 4711 4712 Deprecations 4713 ------------ 4714 4715 - :issue:`4724`: ``pytest.warns()`` now emits a warning when it receives unknown keyword arguments. 4716 4717 This will be changed into an error in the future. 4718 4719 4720 4721 Features 4722 -------- 4723 4724 - :issue:`2753`: Usage errors from argparse are mapped to pytest's ``UsageError``. 4725 4726 4727 - :issue:`3711`: Add the ``--ignore-glob`` parameter to exclude test-modules with Unix shell-style wildcards. 4728 Add the :globalvar:`collect_ignore_glob` for ``conftest.py`` to exclude test-modules with Unix shell-style wildcards. 4729 4730 4731 - :issue:`4698`: The warning about Python 2.7 and 3.4 not being supported in pytest 5.0 has been removed. 4732 4733 In the end it was considered to be more 4734 of a nuisance than actual utility and users of those Python versions shouldn't have problems as ``pip`` will not 4735 install pytest 5.0 on those interpreters. 4736 4737 4738 - :issue:`4707`: With the help of new ``set_log_path()`` method there is a way to set ``log_file`` paths from hooks. 4739 4740 4741 4742 Bug Fixes 4743 --------- 4744 4745 - :issue:`4651`: ``--help`` and ``--version`` are handled with ``UsageError``. 4746 4747 4748 - :issue:`4782`: Fix ``AssertionError`` with collection of broken symlinks with packages. 4749 4750 4751 pytest 4.2.1 (2019-02-12) 4752 ========================= 4753 4754 Bug Fixes 4755 --------- 4756 4757 - :issue:`2895`: The ``pytest_report_collectionfinish`` hook now is also called with ``--collect-only``. 4758 4759 4760 - :issue:`3899`: Do not raise ``UsageError`` when an imported package has a ``pytest_plugins.py`` child module. 4761 4762 4763 - :issue:`4347`: Fix output capturing when using pdb++ with recursive debugging. 4764 4765 4766 - :issue:`4592`: Fix handling of ``collect_ignore`` via parent ``conftest.py``. 4767 4768 4769 - :issue:`4700`: Fix regression where ``setUpClass`` would always be called in subclasses even if all tests 4770 were skipped by a ``unittest.skip()`` decorator applied in the subclass. 4771 4772 4773 - :issue:`4739`: Fix ``parametrize(... ids=<function>)`` when the function returns non-strings. 4774 4775 4776 - :issue:`4745`: Fix/improve collection of args when passing in ``__init__.py`` and a test file. 4777 4778 4779 - :issue:`4770`: ``more_itertools`` is now constrained to <6.0.0 when required for Python 2.7 compatibility. 4780 4781 4782 - :issue:`526`: Fix "ValueError: Plugin already registered" exceptions when running in build directories that symlink to actual source. 4783 4784 4785 4786 Improved Documentation 4787 ---------------------- 4788 4789 - :issue:`3899`: Add note to ``plugins.rst`` that ``pytest_plugins`` should not be used as a name for a user module containing plugins. 4790 4791 4792 - :issue:`4324`: Document how to use ``raises`` and ``does_not_raise`` to write parametrized tests with conditional raises. 4793 4794 4795 - :issue:`4709`: Document how to customize test failure messages when using 4796 ``pytest.warns``. 4797 4798 4799 4800 Trivial/Internal Changes 4801 ------------------------ 4802 4803 - :issue:`4741`: Some verbosity related attributes of the TerminalReporter plugin are now 4804 read only properties. 4805 4806 4807 pytest 4.2.0 (2019-01-30) 4808 ========================= 4809 4810 Features 4811 -------- 4812 4813 - :issue:`3094`: :doc:`Classic xunit-style <how-to/xunit_setup>` functions and methods 4814 now obey the scope of *autouse* fixtures. 4815 4816 This fixes a number of surprising issues like ``setup_method`` being called before session-scoped 4817 autouse fixtures (see :issue:`517` for an example). 4818 4819 4820 - :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 4821 support those Python versions. 4822 4823 4824 - :issue:`4660`: The number of *selected* tests now are also displayed when the ``-k`` or ``-m`` flags are used. 4825 4826 4827 - :issue:`4688`: ``pytest_report_teststatus`` hook now can also receive a ``config`` parameter. 4828 4829 4830 - :issue:`4691`: ``pytest_terminal_summary`` hook now can also receive a ``config`` parameter. 4831 4832 4833 4834 Bug Fixes 4835 --------- 4836 4837 - :issue:`3547`: ``--junitxml`` can emit XML compatible with Jenkins xUnit. 4838 ``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 4839 4840 4841 - :issue:`4280`: Improve quitting from pdb, especially with ``--trace``. 4842 4843 Using ``q[quit]`` after ``pdb.set_trace()`` will quit pytest also. 4844 4845 4846 - :issue:`4402`: Warning summary now groups warnings by message instead of by test id. 4847 4848 This makes the output more compact and better conveys the general idea of how much code is 4849 actually generating warnings, instead of how many tests call that code. 4850 4851 4852 - :issue:`4536`: ``monkeypatch.delattr`` handles class descriptors like ``staticmethod``/``classmethod``. 4853 4854 4855 - :issue:`4649`: Restore marks being considered keywords for keyword expressions. 4856 4857 4858 - :issue:`4653`: ``tmp_path`` fixture and other related ones provides resolved path (a.k.a real path) 4859 4860 4861 - :issue:`4667`: ``pytest_terminal_summary`` uses result from ``pytest_report_teststatus`` hook, rather than hardcoded strings. 4862 4863 4864 - :issue:`4669`: Correctly handle ``unittest.SkipTest`` exception containing non-ascii characters on Python 2. 4865 4866 4867 - :issue:`4680`: Ensure the ``tmpdir`` and the ``tmp_path`` fixtures are the same folder. 4868 4869 4870 - :issue:`4681`: Ensure ``tmp_path`` is always a real path. 4871 4872 4873 4874 Trivial/Internal Changes 4875 ------------------------ 4876 4877 - :issue:`4643`: Use ``a.item()`` instead of the deprecated ``np.asscalar(a)`` in ``pytest.approx``. 4878 4879 ``np.asscalar`` has been :doc:`deprecated <numpy:release/1.16.0-notes>` in ``numpy 1.16.``. 4880 4881 4882 - :issue:`4657`: Copy saferepr from pylib 4883 4884 4885 - :issue:`4668`: The verbose word for expected failures in the teststatus report changes from ``xfail`` to ``XFAIL`` to be consistent with other test outcomes. 4886 4887 4888 pytest 4.1.1 (2019-01-12) 4889 ========================= 4890 4891 Bug Fixes 4892 --------- 4893 4894 - :issue:`2256`: Show full repr with ``assert a==b`` and ``-vv``. 4895 4896 4897 - :issue:`3456`: Extend Doctest-modules to ignore mock objects. 4898 4899 4900 - :issue:`4617`: Fixed ``pytest.warns`` bug when context manager is reused (e.g. multiple parametrization). 4901 4902 4903 - :issue:`4631`: Don't rewrite assertion when ``__getattr__`` is broken 4904 4905 4906 4907 Improved Documentation 4908 ---------------------- 4909 4910 - :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. 4911 4912 4913 4914 Trivial/Internal Changes 4915 ------------------------ 4916 4917 - :issue:`4602`: Uninstall ``hypothesis`` in regen tox env. 4918 4919 4920 pytest 4.1.0 (2019-01-05) 4921 ========================= 4922 4923 Removals 4924 -------- 4925 4926 - :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. 4927 4928 4929 - :issue:`3078`: Remove legacy internal warnings system: ``config.warn``, ``Node.warn``. The ``pytest_logwarning`` now issues a warning when implemented. 4930 4931 See our :ref:`docs <config.warn and node.warn deprecated>` on information on how to update your code. 4932 4933 4934 - :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. 4935 4936 See our :ref:`docs <yield tests deprecated>` on information on how to update your code. 4937 4938 4939 - :issue:`3082`: Removed support for applying marks directly to values in ``@pytest.mark.parametrize``. Use ``pytest.param`` instead. 4940 4941 See our :ref:`docs <marks in pytest.parametrize deprecated>` on information on how to update your code. 4942 4943 4944 - :issue:`3083`: Removed ``Metafunc.addcall``. This was the predecessor mechanism to ``@pytest.mark.parametrize``. 4945 4946 See our :ref:`docs <metafunc.addcall deprecated>` on information on how to update your code. 4947 4948 4949 - :issue:`3085`: Removed support for passing strings to ``pytest.main``. Now, always pass a list of strings instead. 4950 4951 See our :ref:`docs <passing command-line string to pytest.main deprecated>` on information on how to update your code. 4952 4953 4954 - :issue:`3086`: ``[pytest]`` section in **setup.cfg** files is no longer supported, use ``[tool:pytest]`` instead. ``setup.cfg`` files 4955 are meant for use with ``distutils``, and a section named ``pytest`` has notoriously been a source of conflicts and bugs. 4956 4957 Note that for **pytest.ini** and **tox.ini** files the section remains ``[pytest]``. 4958 4959 4960 - :issue:`3616`: Removed the deprecated compat properties for ``node.Class/Function/Module`` - use ``pytest.Class/Function/Module`` now. 4961 4962 See our :ref:`docs <internal classes accessed through node deprecated>` on information on how to update your code. 4963 4964 4965 - :issue:`4421`: Removed the implementation of the ``pytest_namespace`` hook. 4966 4967 See our :ref:`docs <pytest.namespace deprecated>` on information on how to update your code. 4968 4969 4970 - :issue:`4489`: Removed ``request.cached_setup``. This was the predecessor mechanism to modern fixtures. 4971 4972 See our :ref:`docs <cached_setup deprecated>` on information on how to update your code. 4973 4974 4975 - :issue:`4535`: Removed the deprecated ``PyCollector.makeitem`` method. This method was made public by mistake a long time ago. 4976 4977 4978 - :issue:`4543`: Removed support to define fixtures using the ``pytest_funcarg__`` prefix. Use the ``@pytest.fixture`` decorator instead. 4979 4980 See our :ref:`docs <pytest_funcarg__ prefix deprecated>` on information on how to update your code. 4981 4982 4983 - :issue:`4545`: Calling fixtures directly is now always an error instead of a warning. 4984 4985 See our :ref:`docs <calling fixtures directly deprecated>` on information on how to update your code. 4986 4987 4988 - :issue:`4546`: Remove ``Node.get_marker(name)`` the return value was not usable for more than an existence check. 4989 4990 Use ``Node.get_closest_marker(name)`` as a replacement. 4991 4992 4993 - :issue:`4547`: The deprecated ``record_xml_property`` fixture has been removed, use the more generic ``record_property`` instead. 4994 4995 See our :ref:`docs <record_xml_property deprecated>` for more information. 4996 4997 4998 - :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``). 4999 5000 See our :ref:`docs <pytest_plugins in non-top-level conftest files deprecated>` for more information. 5001 5002 5003 - :issue:`891`: Remove ``testfunction.markername`` attributes - use ``Node.iter_markers(name=None)`` to iterate them. 5004 5005 5006 5007 Deprecations 5008 ------------ 5009 5010 - :issue:`3050`: Deprecated the ``pytest.config`` global. 5011 5012 See :ref:`pytest.config global deprecated` for rationale. 5013 5014 5015 - :issue:`3974`: Passing the ``message`` parameter of ``pytest.raises`` now issues a ``DeprecationWarning``. 5016 5017 It is a common mistake to think this parameter will match the exception message, while in fact 5018 it only serves to provide a custom message in case the ``pytest.raises`` check fails. To avoid this 5019 mistake and because it is believed to be little used, pytest is deprecating it without providing 5020 an alternative for the moment. 5021 5022 If you have concerns about this, please comment on :issue:`3974`. 5023 5024 5025 - :issue:`4435`: Deprecated ``raises(..., 'code(as_a_string)')`` and ``warns(..., 'code(as_a_string)')``. 5026 5027 See :std:ref:`raises-warns-exec` for rationale and examples. 5028 5029 5030 5031 Features 5032 -------- 5033 5034 - :issue:`3191`: A warning is now issued when assertions are made for ``None``. 5035 5036 This is a common source of confusion among new users, which write: 5037 5038 .. code-block:: python 5039 5040 assert mocked_object.assert_called_with(3, 4, 5, key="value") 5041 5042 When they should write: 5043 5044 .. code-block:: python 5045 5046 mocked_object.assert_called_with(3, 4, 5, key="value") 5047 5048 Because the ``assert_called_with`` method of mock objects already executes an assertion. 5049 5050 This warning will not be issued when ``None`` is explicitly checked. An assertion like: 5051 5052 .. code-block:: python 5053 5054 assert variable is None 5055 5056 will not issue the warning. 5057 5058 5059 - :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>`). 5060 5061 5062 - :issue:`4278`: ``CACHEDIR.TAG`` files are now created inside cache directories. 5063 5064 Those files are part of the `Cache Directory Tagging Standard <https://bford.info/cachedir/spec.html>`__, and can 5065 be used by backup or synchronization programs to identify pytest's cache directory as such. 5066 5067 5068 - :issue:`4292`: ``pytest.outcomes.Exit`` is derived from ``SystemExit`` instead of ``KeyboardInterrupt``. This allows us to better handle ``pdb`` exiting. 5069 5070 5071 - :issue:`4371`: Updated the ``--collect-only`` option to display test descriptions when ran using ``--verbose``. 5072 5073 5074 - :issue:`4386`: Restructured ``ExceptionInfo`` object construction and ensure incomplete instances have a ``repr``/``str``. 5075 5076 5077 - :issue:`4416`: pdb: added support for keyword arguments with ``pdb.set_trace``. 5078 5079 It handles ``header`` similar to Python 3.7 does it, and forwards any 5080 other keyword arguments to the ``Pdb`` constructor. 5081 5082 This allows for ``__import__("pdb").set_trace(skip=["foo.*"])``. 5083 5084 5085 - :issue:`4483`: Added ini parameter ``junit_duration_report`` to optionally report test call durations, excluding setup and teardown times. 5086 5087 The JUnit XML specification and the default pytest behavior is to include setup and teardown times in the test duration 5088 report. You can include just the call durations instead (excluding setup and teardown) by adding this to your ``pytest.ini`` file: 5089 5090 .. code-block:: ini 5091 5092 [pytest] 5093 junit_duration_report = call 5094 5095 5096 - :issue:`4532`: ``-ra`` now will show errors and failures last, instead of as the first items in the summary. 5097 5098 This makes it easier to obtain a list of errors and failures to run tests selectively. 5099 5100 5101 - :issue:`4599`: ``pytest.importorskip`` now supports a ``reason`` parameter, which will be shown when the 5102 requested module cannot be imported. 5103 5104 5105 5106 Bug Fixes 5107 --------- 5108 5109 - :issue:`3532`: ``-p`` now accepts its argument without a space between the value, for example ``-pmyplugin``. 5110 5111 5112 - :issue:`4327`: ``approx`` again works with more generic containers, more precisely instances of ``Iterable`` and ``Sized`` instead of more restrictive ``Sequence``. 5113 5114 5115 - :issue:`4397`: Ensure that node ids are printable. 5116 5117 5118 - :issue:`4435`: Fixed ``raises(..., 'code(string)')`` frame filename. 5119 5120 5121 - :issue:`4458`: Display actual test ids in ``--collect-only``. 5122 5123 5124 5125 Improved Documentation 5126 ---------------------- 5127 5128 - :issue:`4557`: Markers example documentation page updated to support latest pytest version. 5129 5130 5131 - :issue:`4558`: Update cache documentation example to correctly show cache hit and miss. 5132 5133 5134 - :issue:`4580`: Improved detailed summary report documentation. 5135 5136 5137 5138 Trivial/Internal Changes 5139 ------------------------ 5140 5141 - :issue:`4447`: Changed the deprecation type of ``--result-log`` to ``PytestDeprecationWarning``. 5142 5143 It was decided to remove this feature at the next major revision. 5144 5145 5146 pytest 4.0.2 (2018-12-13) 5147 ========================= 5148 5149 Bug Fixes 5150 --------- 5151 5152 - :issue:`4265`: Validate arguments from the ``PYTEST_ADDOPTS`` environment variable and the ``addopts`` ini option separately. 5153 5154 5155 - :issue:`4435`: Fix ``raises(..., 'code(string)')`` frame filename. 5156 5157 5158 - :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``. 5159 5160 5161 - :issue:`4538`: Raise ``TypeError`` for ``with raises(..., match=<non-None falsey value>)``. 5162 5163 5164 5165 Improved Documentation 5166 ---------------------- 5167 5168 - :issue:`1495`: Document common doctest fixture directory tree structure pitfalls 5169 5170 5171 pytest 4.0.1 (2018-11-23) 5172 ========================= 5173 5174 Bug Fixes 5175 --------- 5176 5177 - :issue:`3952`: Display warnings before "short test summary info" again, but still later warnings in the end. 5178 5179 5180 - :issue:`4386`: Handle uninitialized exceptioninfo in repr/str. 5181 5182 5183 - :issue:`4393`: Do not create ``.gitignore``/``README.md`` files in existing cache directories. 5184 5185 5186 - :issue:`4400`: Rearrange warning handling for the yield test errors so the opt-out in 4.0.x correctly works. 5187 5188 5189 - :issue:`4405`: Fix collection of testpaths with ``--pyargs``. 5190 5191 5192 - :issue:`4412`: Fix assertion rewriting involving ``Starred`` + side-effects. 5193 5194 5195 - :issue:`4425`: Ensure we resolve the absolute path when the given ``--basetemp`` is a relative path. 5196 5197 5198 5199 Trivial/Internal Changes 5200 ------------------------ 5201 5202 - :issue:`4315`: Use ``pkg_resources.parse_version`` instead of ``LooseVersion`` in minversion check. 5203 5204 5205 - :issue:`4440`: Adjust the stack level of some internal pytest warnings. 5206 5207 5208 pytest 4.0.0 (2018-11-13) 5209 ========================= 5210 5211 Removals 5212 -------- 5213 5214 - :issue:`3737`: **RemovedInPytest4Warnings are now errors by default.** 5215 5216 Following our plan to remove deprecated features with as little disruption as 5217 possible, all warnings of type ``RemovedInPytest4Warnings`` now generate errors 5218 instead of warning messages. 5219 5220 **The affected features will be effectively removed in pytest 4.1**, so please consult the 5221 :std:doc:`deprecations` section in the docs for directions on how to update existing code. 5222 5223 In the pytest ``4.0.X`` series, it is possible to change the errors back into warnings as a stop 5224 gap measure by adding this to your ``pytest.ini`` file: 5225 5226 .. code-block:: ini 5227 5228 [pytest] 5229 filterwarnings = 5230 ignore::pytest.RemovedInPytest4Warning 5231 5232 But this will stop working when pytest ``4.1`` is released. 5233 5234 **If you have concerns** about the removal of a specific feature, please add a 5235 comment to :issue:`4348`. 5236 5237 5238 - :issue:`4358`: Remove the ``::()`` notation to denote a test class instance in node ids. 5239 5240 Previously, node ids that contain test instances would use ``::()`` to denote the instance like this:: 5241 5242 test_foo.py::Test::()::test_bar 5243 5244 The extra ``::()`` was puzzling to most users and has been removed, so that the test id becomes now:: 5245 5246 test_foo.py::Test::test_bar 5247 5248 This change could not accompany a deprecation period as is usual when user-facing functionality changes because 5249 it was not really possible to detect when the functionality was being used explicitly. 5250 5251 The extra ``::()`` might have been removed in some places internally already, 5252 which then led to confusion in places where it was expected, e.g. with 5253 ``--deselect`` (:issue:`4127`). 5254 5255 Test class instances are also not listed with ``--collect-only`` anymore. 5256 5257 5258 5259 Features 5260 -------- 5261 5262 - :issue:`4270`: The ``cache_dir`` option uses ``$TOX_ENV_DIR`` as prefix (if set in the environment). 5263 5264 This uses a different cache per tox environment by default. 5265 5266 5267 5268 Bug Fixes 5269 --------- 5270 5271 - :issue:`3554`: Fix ``CallInfo.__repr__`` for when the call is not finished yet. 5272 5273 5274 pytest 3.10.1 (2018-11-11) 5275 ========================== 5276 5277 Bug Fixes 5278 --------- 5279 5280 - :issue:`4287`: Fix nested usage of debugging plugin (pdb), e.g. with pytester's ``testdir.runpytest``. 5281 5282 5283 - :issue:`4304`: Block the ``stepwise`` plugin if ``cacheprovider`` is also blocked, as one depends on the other. 5284 5285 5286 - :issue:`4306`: Parse ``minversion`` as an actual version and not as dot-separated strings. 5287 5288 5289 - :issue:`4310`: Fix duplicate collection due to multiple args matching the same packages. 5290 5291 5292 - :issue:`4321`: Fix ``item.nodeid`` with resolved symlinks. 5293 5294 5295 - :issue:`4325`: Fix collection of direct symlinked files, where the target does not match ``python_files``. 5296 5297 5298 - :issue:`4329`: Fix TypeError in report_collect with _collect_report_last_write. 5299 5300 5301 5302 Trivial/Internal Changes 5303 ------------------------ 5304 5305 - :issue:`4305`: Replace byte/unicode helpers in test_capture with python level syntax. 5306 5307 5308 pytest 3.10.0 (2018-11-03) 5309 ========================== 5310 5311 Features 5312 -------- 5313 5314 - :issue:`2619`: Resume capturing output after ``continue`` with ``__import__("pdb").set_trace()``. 5315 5316 This also adds a new ``pytest_leave_pdb`` hook, and passes in ``pdb`` to the 5317 existing ``pytest_enter_pdb`` hook. 5318 5319 5320 - :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. 5321 5322 5323 - :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. 5324 5325 5326 - :issue:`4225`: Improve performance with collection reporting in non-quiet mode with terminals. 5327 5328 The "collecting …" message is only printed/updated every 0.5s. 5329 5330 5331 5332 Bug Fixes 5333 --------- 5334 5335 - :issue:`2701`: Fix false ``RemovedInPytest4Warning: usage of Session... is deprecated, please use pytest`` warnings. 5336 5337 5338 - :issue:`4046`: Fix problems with running tests in package ``__init__.py`` files. 5339 5340 5341 - :issue:`4260`: Swallow warnings during anonymous compilation of source. 5342 5343 5344 - :issue:`4262`: Fix access denied error when deleting stale directories created by ``tmpdir`` / ``tmp_path``. 5345 5346 5347 - :issue:`611`: Naming a fixture ``request`` will now raise a warning: the ``request`` fixture is internal and 5348 should not be overwritten as it will lead to internal errors. 5349 5350 - :issue:`4266`: Handle (ignore) exceptions raised during collection, e.g. with Django's LazySettings proxy class. 5351 5352 5353 5354 Improved Documentation 5355 ---------------------- 5356 5357 - :issue:`4255`: Added missing documentation about the fact that module names passed to filter warnings are not regex-escaped. 5358 5359 5360 5361 Trivial/Internal Changes 5362 ------------------------ 5363 5364 - :issue:`4272`: Display cachedir also in non-verbose mode if non-default. 5365 5366 5367 - :issue:`4277`: pdb: improve message about output capturing with ``set_trace``. 5368 5369 Do not display "IO-capturing turned off/on" when ``-s`` is used to avoid 5370 confusion. 5371 5372 5373 - :issue:`4279`: Improve message and stack level of warnings issued by ``monkeypatch.setenv`` when the value of the environment variable is not a ``str``. 5374 5375 5376 pytest 3.9.3 (2018-10-27) 5377 ========================= 5378 5379 Bug Fixes 5380 --------- 5381 5382 - :issue:`4174`: Fix "ValueError: Plugin already registered" with conftest plugins via symlink. 5383 5384 5385 - :issue:`4181`: Handle race condition between creation and deletion of temporary folders. 5386 5387 5388 - :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. 5389 5390 5391 - :issue:`4243`: Fix regression when ``stacklevel`` for warnings was passed as positional argument on python2. 5392 5393 5394 5395 Improved Documentation 5396 ---------------------- 5397 5398 - :issue:`3851`: Add reference to ``empty_parameter_set_mark`` ini option in documentation of ``@pytest.mark.parametrize`` 5399 5400 5401 5402 Trivial/Internal Changes 5403 ------------------------ 5404 5405 - :issue:`4028`: Revert patching of ``sys.breakpointhook`` since it appears to do nothing. 5406 5407 5408 - :issue:`4233`: Apply an import sorter (``reorder-python-imports``) to the codebase. 5409 5410 5411 - :issue:`4248`: Remove use of unnecessary compat shim, six.binary_type 5412 5413 5414 pytest 3.9.2 (2018-10-22) 5415 ========================= 5416 5417 Bug Fixes 5418 --------- 5419 5420 - :issue:`2909`: Improve error message when a recursive dependency between fixtures is detected. 5421 5422 5423 - :issue:`3340`: Fix logging messages not shown in hooks ``pytest_sessionstart()`` and ``pytest_sessionfinish()``. 5424 5425 5426 - :issue:`3533`: Fix unescaped XML raw objects in JUnit report for skipped tests 5427 5428 5429 - :issue:`3691`: Python 2: safely format warning message about passing unicode strings to ``warnings.warn``, which may cause 5430 surprising ``MemoryError`` exception when monkey patching ``warnings.warn`` itself. 5431 5432 5433 - :issue:`4026`: Improve error message when it is not possible to determine a function's signature. 5434 5435 5436 - :issue:`4177`: Pin ``setuptools>=40.0`` to support ``py_modules`` in ``setup.cfg`` 5437 5438 5439 - :issue:`4179`: Restore the tmpdir behaviour of symlinking the current test run. 5440 5441 5442 - :issue:`4192`: Fix filename reported by ``warnings.warn`` when using ``recwarn`` under python2. 5443 5444 5445 pytest 3.9.1 (2018-10-16) 5446 ========================= 5447 5448 Features 5449 -------- 5450 5451 - :issue:`4159`: For test-suites containing test classes, the information about the subclassed 5452 module is now output only if a higher verbosity level is specified (at least 5453 "-vv"). 5454 5455 5456 pytest 3.9.0 (2018-10-15 - not published due to a release automation bug) 5457 ========================================================================= 5458 5459 Deprecations 5460 ------------ 5461 5462 - :issue:`3616`: The following accesses have been documented as deprecated for years, but are now actually emitting deprecation warnings. 5463 5464 * Access of ``Module``, ``Function``, ``Class``, ``Instance``, ``File`` and ``Item`` through ``Node`` instances. Now 5465 users will this warning:: 5466 5467 usage of Function.Module is deprecated, please use pytest.Module instead 5468 5469 Users should just ``import pytest`` and access those objects using the ``pytest`` module. 5470 5471 * ``request.cached_setup``, this was the precursor of the setup/teardown mechanism available to fixtures. You can 5472 consult :std:doc:`funcarg comparison section in the docs <funcarg_compare>`. 5473 5474 * Using objects named ``"Class"`` as a way to customize the type of nodes that are collected in ``Collector`` 5475 subclasses has been deprecated. Users instead should use ``pytest_collect_make_item`` to customize node types during 5476 collection. 5477 5478 This issue should affect only advanced plugins who create new collection types, so if you see this warning 5479 message please contact the authors so they can change the code. 5480 5481 * The warning that produces the message below has changed to ``RemovedInPytest4Warning``:: 5482 5483 getfuncargvalue is deprecated, use getfixturevalue 5484 5485 5486 - :issue:`3988`: Add a Deprecation warning for pytest.ensuretemp as it was deprecated since a while. 5487 5488 5489 5490 Features 5491 -------- 5492 5493 - :issue:`2293`: Improve usage errors messages by hiding internal details which can be distracting and noisy. 5494 5495 This has the side effect that some error conditions that previously raised generic errors (such as 5496 ``ValueError`` for unregistered marks) are now raising ``Failed`` exceptions. 5497 5498 5499 - :issue:`3332`: Improve the error displayed when a ``conftest.py`` file could not be imported. 5500 5501 In order to implement this, a new ``chain`` parameter was added to ``ExceptionInfo.getrepr`` 5502 to show or hide chained tracebacks in Python 3 (defaults to ``True``). 5503 5504 5505 - :issue:`3849`: Add ``empty_parameter_set_mark=fail_at_collect`` ini option for raising an exception when parametrize collects an empty set. 5506 5507 5508 - :issue:`3964`: Log messages generated in the collection phase are shown when 5509 live-logging is enabled and/or when they are logged to a file. 5510 5511 5512 - :issue:`3985`: Introduce ``tmp_path`` as a fixture providing a Path object. Also introduce ``tmp_path_factory`` as 5513 a session-scoped fixture for creating arbitrary temporary directories from any other fixture or test. 5514 5515 5516 - :issue:`4013`: Deprecation warnings are now shown even if you customize the warnings filters yourself. In the previous version 5517 any customization would override pytest's filters and deprecation warnings would fall back to being hidden by default. 5518 5519 5520 - :issue:`4073`: Allow specification of timeout for ``Testdir.runpytest_subprocess()`` and ``Testdir.run()``. 5521 5522 5523 - :issue:`4098`: Add returncode argument to pytest.exit() to exit pytest with a specific return code. 5524 5525 5526 - :issue:`4102`: Reimplement ``pytest.deprecated_call`` using ``pytest.warns`` so it supports the ``match='...'`` keyword argument. 5527 5528 This has the side effect that ``pytest.deprecated_call`` now raises ``pytest.fail.Exception`` instead 5529 of ``AssertionError``. 5530 5531 5532 - :issue:`4149`: Require setuptools>=30.3 and move most of the metadata to ``setup.cfg``. 5533 5534 5535 5536 Bug Fixes 5537 --------- 5538 5539 - :issue:`2535`: Improve error message when test functions of ``unittest.TestCase`` subclasses use a parametrized fixture. 5540 5541 5542 - :issue:`3057`: ``request.fixturenames`` now correctly returns the name of fixtures created by ``request.getfixturevalue()``. 5543 5544 5545 - :issue:`3946`: Warning filters passed as command line options using ``-W`` now take precedence over filters defined in ``ini`` 5546 configuration files. 5547 5548 5549 - :issue:`4066`: Fix source reindenting by using ``textwrap.dedent`` directly. 5550 5551 5552 - :issue:`4102`: ``pytest.warn`` will capture previously-warned warnings in Python 2. Previously they were never raised. 5553 5554 5555 - :issue:`4108`: Resolve symbolic links for args. 5556 5557 This fixes running ``pytest tests/test_foo.py::test_bar``, where ``tests`` 5558 is a symlink to ``project/app/tests``: 5559 previously ``project/app/conftest.py`` would be ignored for fixtures then. 5560 5561 5562 - :issue:`4132`: Fix duplicate printing of internal errors when using ``--pdb``. 5563 5564 5565 - :issue:`4135`: pathlib based tmpdir cleanup now correctly handles symlinks in the folder. 5566 5567 5568 - :issue:`4152`: Display the filename when encountering ``SyntaxWarning``. 5569 5570 5571 5572 Improved Documentation 5573 ---------------------- 5574 5575 - :issue:`3713`: Update usefixtures documentation to clarify that it can't be used with fixture functions. 5576 5577 5578 - :issue:`4058`: Update fixture documentation to specify that a fixture can be invoked twice in the scope it's defined for. 5579 5580 5581 - :issue:`4064`: According to unittest.rst, setUpModule and tearDownModule were not implemented, but it turns out they are. So updated the documentation for unittest. 5582 5583 5584 - :issue:`4151`: Add tempir testing example to CONTRIBUTING.rst guide 5585 5586 5587 5588 Trivial/Internal Changes 5589 ------------------------ 5590 5591 - :issue:`2293`: The internal ``MarkerError`` exception has been removed. 5592 5593 5594 - :issue:`3988`: Port the implementation of tmpdir to pathlib. 5595 5596 5597 - :issue:`4063`: Exclude 0.00 second entries from ``--duration`` output unless ``-vv`` is passed on the command-line. 5598 5599 5600 - :issue:`4093`: Fixed formatting of string literals in internal tests. 5601 5602 5603 pytest 3.8.2 (2018-10-02) 5604 ========================= 5605 5606 Deprecations and Removals 5607 ------------------------- 5608 5609 - :issue:`4036`: The ``item`` parameter of ``pytest_warning_captured`` hook is now documented as deprecated. We realized only after 5610 the ``3.8`` release that this parameter is incompatible with ``pytest-xdist``. 5611 5612 Our policy is to not deprecate features during bug-fix releases, but in this case we believe it makes sense as we are 5613 only documenting it as deprecated, without issuing warnings which might potentially break test suites. This will get 5614 the word out that hook implementers should not use this parameter at all. 5615 5616 In a future release ``item`` will always be ``None`` and will emit a proper warning when a hook implementation 5617 makes use of it. 5618 5619 5620 5621 Bug Fixes 5622 --------- 5623 5624 - :issue:`3539`: Fix reload on assertion rewritten modules. 5625 5626 5627 - :issue:`4034`: The ``.user_properties`` attribute of ``TestReport`` objects is a list 5628 of (name, value) tuples, but could sometimes be instantiated as a tuple 5629 of tuples. It is now always a list. 5630 5631 5632 - :issue:`4039`: No longer issue warnings about using ``pytest_plugins`` in non-top-level directories when using ``--pyargs``: the 5633 current ``--pyargs`` mechanism is not reliable and might give false negatives. 5634 5635 5636 - :issue:`4040`: Exclude empty reports for passed tests when ``-rP`` option is used. 5637 5638 5639 - :issue:`4051`: Improve error message when an invalid Python expression is passed to the ``-m`` option. 5640 5641 5642 - :issue:`4056`: ``MonkeyPatch.setenv`` and ``MonkeyPatch.delenv`` issue a warning if the environment variable name is not ``str`` on Python 2. 5643 5644 In Python 2, adding ``unicode`` keys to ``os.environ`` causes problems with ``subprocess`` (and possible other modules), 5645 making this a subtle bug specially susceptible when used with ``from __future__ import unicode_literals``. 5646 5647 5648 5649 Improved Documentation 5650 ---------------------- 5651 5652 - :issue:`3928`: Add possible values for fixture scope to docs. 5653 5654 5655 pytest 3.8.1 (2018-09-22) 5656 ========================= 5657 5658 Bug Fixes 5659 --------- 5660 5661 - :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. 5662 5663 5664 - :issue:`3749`: Fix the following error during collection of tests inside packages:: 5665 5666 TypeError: object of type 'Package' has no len() 5667 5668 5669 - :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. 5670 5671 5672 - :issue:`3973`: Fix crash of the assertion rewriter if a test changed the current working directory without restoring it afterwards. 5673 5674 5675 - :issue:`3998`: Fix issue that prevented some caplog properties (for example ``record_tuples``) from being available when entering the debugger with ``--pdb``. 5676 5677 5678 - :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. 5679 5680 5681 5682 Improved Documentation 5683 ---------------------- 5684 5685 - :issue:`3996`: New :std:doc:`deprecations` page shows all currently 5686 deprecated features, the rationale to do so, and alternatives to update your code. It also list features removed 5687 from pytest in past major releases to help those with ancient pytest versions to upgrade. 5688 5689 5690 5691 Trivial/Internal Changes 5692 ------------------------ 5693 5694 - :issue:`3955`: Improve pre-commit detection for changelog filenames 5695 5696 5697 - :issue:`3975`: Remove legacy code around im_func as that was python2 only 5698 5699 5700 pytest 3.8.0 (2018-09-05) 5701 ========================= 5702 5703 Deprecations and Removals 5704 ------------------------- 5705 5706 - :issue:`2452`: ``Config.warn`` and ``Node.warn`` have been 5707 deprecated, see :ref:`config.warn and node.warn deprecated` for rationale and 5708 examples. 5709 5710 - :issue:`3936`: ``@pytest.mark.filterwarnings`` second parameter is no longer regex-escaped, 5711 making it possible to actually use regular expressions to check the warning message. 5712 5713 **Note**: regex-escaping the match string was an implementation oversight that might break test suites which depend 5714 on the old behavior. 5715 5716 5717 5718 Features 5719 -------- 5720 5721 - :issue:`2452`: Internal pytest warnings are now issued using the standard ``warnings`` module, making it possible to use 5722 the standard warnings filters to manage those warnings. This introduces ``PytestWarning``, 5723 ``PytestDeprecationWarning`` and ``RemovedInPytest4Warning`` warning types as part of the public API. 5724 5725 Consult :ref:`the documentation <internal-warnings>` for more info. 5726 5727 5728 - :issue:`2908`: ``DeprecationWarning`` and ``PendingDeprecationWarning`` are now shown by default if no other warning filter is 5729 configured. This makes pytest more compliant with 5730 :pep:`506#recommended-filter-settings-for-test-runners`. See 5731 :ref:`the docs <deprecation-warnings>` for 5732 more info. 5733 5734 5735 - :issue:`3251`: Warnings are now captured and displayed during test collection. 5736 5737 5738 - :issue:`3784`: ``PYTEST_DISABLE_PLUGIN_AUTOLOAD`` environment variable disables plugin auto-loading when set. 5739 5740 5741 - :issue:`3829`: Added the ``count`` option to ``console_output_style`` to enable displaying the progress as a count instead of a percentage. 5742 5743 5744 - :issue:`3837`: Added support for 'xfailed' and 'xpassed' outcomes to the ``pytester.RunResult.assert_outcomes`` signature. 5745 5746 5747 5748 Bug Fixes 5749 --------- 5750 5751 - :issue:`3911`: Terminal writer now takes into account unicode character width when writing out progress. 5752 5753 5754 - :issue:`3913`: Pytest now returns with correct exit code (EXIT_USAGEERROR, 4) when called with unknown arguments. 5755 5756 5757 - :issue:`3918`: Improve performance of assertion rewriting. 5758 5759 5760 5761 Improved Documentation 5762 ---------------------- 5763 5764 - :issue:`3566`: Added a blurb in usage.rst for the usage of -r flag which is used to show an extra test summary info. 5765 5766 5767 - :issue:`3907`: Corrected type of the exceptions collection passed to ``xfail``: ``raises`` argument accepts a ``tuple`` instead of ``list``. 5768 5769 5770 5771 Trivial/Internal Changes 5772 ------------------------ 5773 5774 - :issue:`3853`: Removed ``"run all (no recorded failures)"`` message printed with ``--failed-first`` and ``--last-failed`` when there are no failed tests. 5775 5776 5777 pytest 3.7.4 (2018-08-29) 5778 ========================= 5779 5780 Bug Fixes 5781 --------- 5782 5783 - :issue:`3506`: Fix possible infinite recursion when writing ``.pyc`` files. 5784 5785 5786 - :issue:`3853`: Cache plugin now obeys the ``-q`` flag when ``--last-failed`` and ``--failed-first`` flags are used. 5787 5788 5789 - :issue:`3883`: Fix bad console output when using ``console_output_style=classic``. 5790 5791 5792 - :issue:`3888`: Fix macOS specific code using ``capturemanager`` plugin in doctests. 5793 5794 5795 5796 Improved Documentation 5797 ---------------------- 5798 5799 - :issue:`3902`: Fix pytest.org links 5800 5801 5802 pytest 3.7.3 (2018-08-26) 5803 ========================= 5804 5805 Bug Fixes 5806 --------- 5807 5808 - :issue:`3033`: Fixtures during teardown can again use ``capsys`` and ``capfd`` to inspect output captured during tests. 5809 5810 5811 - :issue:`3773`: Fix collection of tests from ``__init__.py`` files if they match the ``python_files`` configuration option. 5812 5813 5814 - :issue:`3796`: Fix issue where teardown of fixtures of consecutive sub-packages were executed once, at the end of the outer 5815 package. 5816 5817 5818 - :issue:`3816`: Fix bug where ``--show-capture=no`` option would still show logs printed during fixture teardown. 5819 5820 5821 - :issue:`3819`: Fix ``stdout/stderr`` not getting captured when real-time cli logging is active. 5822 5823 5824 - :issue:`3843`: Fix collection error when specifying test functions directly in the command line using ``test.py::test`` syntax together with ``--doctest-modules``. 5825 5826 5827 - :issue:`3848`: Fix bugs where unicode arguments could not be passed to ``testdir.runpytest`` on Python 2. 5828 5829 5830 - :issue:`3854`: Fix double collection of tests within packages when the filename starts with a capital letter. 5831 5832 5833 5834 Improved Documentation 5835 ---------------------- 5836 5837 - :issue:`3824`: Added example for multiple glob pattern matches in ``python_files``. 5838 5839 5840 - :issue:`3833`: Added missing docs for ``pytester.Testdir``. 5841 5842 5843 - :issue:`3870`: Correct documentation for setuptools integration. 5844 5845 5846 5847 Trivial/Internal Changes 5848 ------------------------ 5849 5850 - :issue:`3826`: Replace broken type annotations with type comments. 5851 5852 5853 - :issue:`3845`: Remove a reference to issue :issue:`568` from the documentation, which has since been 5854 fixed. 5855 5856 5857 pytest 3.7.2 (2018-08-16) 5858 ========================= 5859 5860 Bug Fixes 5861 --------- 5862 5863 - :issue:`3671`: Fix ``filterwarnings`` not being registered as a builtin mark. 5864 5865 5866 - :issue:`3768`, :issue:`3789`: Fix test collection from packages mixed with normal directories. 5867 5868 5869 - :issue:`3771`: Fix infinite recursion during collection if a ``pytest_ignore_collect`` hook returns ``False`` instead of ``None``. 5870 5871 5872 - :issue:`3774`: Fix bug where decorated fixtures would lose functionality (for example ``@mock.patch``). 5873 5874 5875 - :issue:`3775`: Fix bug where importing modules or other objects with prefix ``pytest_`` prefix would raise a ``PluginValidationError``. 5876 5877 5878 - :issue:`3788`: Fix ``AttributeError`` during teardown of ``TestCase`` subclasses which raise an exception during ``__init__``. 5879 5880 5881 - :issue:`3804`: Fix traceback reporting for exceptions with ``__cause__`` cycles. 5882 5883 5884 5885 Improved Documentation 5886 ---------------------- 5887 5888 - :issue:`3746`: Add documentation for ``metafunc.config`` that had been mistakenly hidden. 5889 5890 5891 pytest 3.7.1 (2018-08-02) 5892 ========================= 5893 5894 Bug Fixes 5895 --------- 5896 5897 - :issue:`3473`: Raise immediately if ``approx()`` is given an expected value of a type it doesn't understand (e.g. strings, nested dicts, etc.). 5898 5899 5900 - :issue:`3712`: Correctly represent the dimensions of a numpy array when calling ``repr()`` on ``approx()``. 5901 5902 - :issue:`3742`: Fix incompatibility with third party plugins during collection, which produced the error ``object has no attribute '_collectfile'``. 5903 5904 - :issue:`3745`: Display the absolute path if ``cache_dir`` is not relative to the ``rootdir`` instead of failing. 5905 5906 5907 - :issue:`3747`: Fix compatibility problem with plugins and the warning code issued by fixture functions when they are called directly. 5908 5909 5910 - :issue:`3748`: Fix infinite recursion in ``pytest.approx`` with arrays in ``numpy<1.13``. 5911 5912 5913 - :issue:`3757`: Pin pathlib2 to ``>=2.2.0`` as we require ``__fspath__`` support. 5914 5915 5916 - :issue:`3763`: Fix ``TypeError`` when the assertion message is ``bytes`` in python 3. 5917 5918 5919 pytest 3.7.0 (2018-07-30) 5920 ========================= 5921 5922 Deprecations and Removals 5923 ------------------------- 5924 5925 - :issue:`2639`: ``pytest_namespace`` has been :ref:`deprecated <pytest.namespace deprecated>`. 5926 5927 5928 - :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>`. 5929 5930 5931 5932 Features 5933 -------- 5934 5935 - :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. 5936 5937 5938 - :issue:`3576`: ``Node.add_marker`` now supports an ``append=True/False`` parameter to determine whether the mark comes last (default) or first. 5939 5940 5941 - :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. 5942 5943 5944 - :issue:`3610`: New ``--trace`` option to enter the debugger at the start of a test. 5945 5946 5947 - :issue:`3623`: Introduce ``pytester.copy_example`` as helper to do acceptance tests against examples from the project. 5948 5949 5950 5951 Bug Fixes 5952 --------- 5953 5954 - :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. 5955 5956 5957 - :issue:`3695`: Fix ``ApproxNumpy`` initialisation argument mixup, ``abs`` and ``rel`` tolerances were flipped causing strange comparison results. 5958 Add tests to check ``abs`` and ``rel`` tolerances for ``np.array`` and test for expecting ``nan`` with ``np.array()`` 5959 5960 5961 - :issue:`980`: Fix truncated locals output in verbose mode. 5962 5963 5964 5965 Improved Documentation 5966 ---------------------- 5967 5968 - :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. 5969 5970 5971 5972 Trivial/Internal Changes 5973 ------------------------ 5974 5975 - :issue:`3519`: Now a ``README.md`` file is created in ``.pytest_cache`` to make it clear why the directory exists. 5976 5977 5978 pytest 3.6.4 (2018-07-28) 5979 ========================= 5980 5981 Bug Fixes 5982 --------- 5983 5984 - Invoke pytest using ``-mpytest`` so ``sys.path`` does not get polluted by packages installed in ``site-packages``. (:issue:`742`) 5985 5986 5987 Improved Documentation 5988 ---------------------- 5989 5990 - Use ``smtp_connection`` instead of ``smtp`` in fixtures documentation to avoid possible confusion. (:issue:`3592`) 5991 5992 5993 Trivial/Internal Changes 5994 ------------------------ 5995 5996 - Remove obsolete ``__future__`` imports. (:issue:`2319`) 5997 5998 - Add CITATION to provide information on how to formally cite pytest. (:issue:`3402`) 5999 6000 - Replace broken type annotations with type comments. (:issue:`3635`) 6001 6002 - Pin ``pluggy`` to ``<0.8``. (:issue:`3727`) 6003 6004 6005 pytest 3.6.3 (2018-07-04) 6006 ========================= 6007 6008 Bug Fixes 6009 --------- 6010 6011 - Fix ``ImportWarning`` triggered by explicit relative imports in 6012 assertion-rewritten package modules. (:issue:`3061`) 6013 6014 - Fix error in ``pytest.approx`` when dealing with 0-dimension numpy 6015 arrays. (:issue:`3593`) 6016 6017 - No longer raise ``ValueError`` when using the ``get_marker`` API. (:issue:`3605`) 6018 6019 - Fix problem where log messages with non-ascii characters would not 6020 appear in the output log file. 6021 (:issue:`3630`) 6022 6023 - No longer raise ``AttributeError`` when legacy marks can't be stored in 6024 functions. (:issue:`3631`) 6025 6026 6027 Improved Documentation 6028 ---------------------- 6029 6030 - The description above the example for ``@pytest.mark.skipif`` now better 6031 matches the code. (:issue:`3611`) 6032 6033 6034 Trivial/Internal Changes 6035 ------------------------ 6036 6037 - Internal refactoring: removed unused ``CallSpec2tox ._globalid_args`` 6038 attribute and ``metafunc`` parameter from ``CallSpec2.copy()``. (:issue:`3598`) 6039 6040 - Silence usage of ``reduce`` warning in Python 2 (:issue:`3609`) 6041 6042 - Fix usage of ``attr.ib`` deprecated ``convert`` parameter. (:issue:`3653`) 6043 6044 6045 pytest 3.6.2 (2018-06-20) 6046 ========================= 6047 6048 Bug Fixes 6049 --------- 6050 6051 - Fix regression in ``Node.add_marker`` by extracting the mark object of a 6052 ``MarkDecorator``. (:issue:`3555`) 6053 6054 - Warnings without ``location`` were reported as ``None``. This is corrected to 6055 now report ``<undetermined location>``. (:issue:`3563`) 6056 6057 - Continue to call finalizers in the stack when a finalizer in a former scope 6058 raises an exception. (:issue:`3569`) 6059 6060 - Fix encoding error with ``print`` statements in doctests (:issue:`3583`) 6061 6062 6063 Improved Documentation 6064 ---------------------- 6065 6066 - Add documentation for the ``--strict`` flag. (:issue:`3549`) 6067 6068 6069 Trivial/Internal Changes 6070 ------------------------ 6071 6072 - Update old quotation style to parens in fixture.rst documentation. (:issue:`3525`) 6073 6074 - Improve display of hint about ``--fulltrace`` with ``KeyboardInterrupt``. 6075 (:issue:`3545`) 6076 6077 - pytest's testsuite is no longer runnable through ``python setup.py test`` -- 6078 instead invoke ``pytest`` or ``tox`` directly. (:issue:`3552`) 6079 6080 - Fix typo in documentation (:issue:`3567`) 6081 6082 6083 pytest 3.6.1 (2018-06-05) 6084 ========================= 6085 6086 Bug Fixes 6087 --------- 6088 6089 - Fixed a bug where stdout and stderr were logged twice by junitxml when a test 6090 was marked xfail. (:issue:`3491`) 6091 6092 - Fix ``usefixtures`` mark applied to unittest tests by correctly instantiating 6093 ``FixtureInfo``. (:issue:`3498`) 6094 6095 - Fix assertion rewriter compatibility with libraries that monkey patch 6096 ``file`` objects. (:issue:`3503`) 6097 6098 6099 Improved Documentation 6100 ---------------------- 6101 6102 - Added a section on how to use fixtures as factories to the fixture 6103 documentation. (:issue:`3461`) 6104 6105 6106 Trivial/Internal Changes 6107 ------------------------ 6108 6109 - Enable caching for pip/pre-commit in order to reduce build time on 6110 travis/appveyor. (:issue:`3502`) 6111 6112 - Switch pytest to the src/ layout as we already suggested it for good practice 6113 - now we implement it as well. (:issue:`3513`) 6114 6115 - Fix if in tests to support 3.7.0b5, where a docstring handling in AST got 6116 reverted. (:issue:`3530`) 6117 6118 - Remove some python2.5 compatibility code. (:issue:`3529`) 6119 6120 6121 pytest 3.6.0 (2018-05-23) 6122 ========================= 6123 6124 Features 6125 -------- 6126 6127 - Revamp the internals of the ``pytest.mark`` implementation with correct per 6128 node handling which fixes a number of long standing bugs caused by the old 6129 design. This introduces new ``Node.iter_markers(name)`` and 6130 ``Node.get_closest_marker(name)`` APIs. Users are **strongly encouraged** to 6131 read the :ref:`reasons for the revamp in the docs <marker-revamp>`, 6132 or jump over to details about :ref:`updating existing code to use the new APIs 6133 <update marker code>`. 6134 (:issue:`3317`) 6135 6136 - Now when ``@pytest.fixture`` is applied more than once to the same function a 6137 ``ValueError`` is raised. This buggy behavior would cause surprising problems 6138 and if was working for a test suite it was mostly by accident. (:issue:`2334`) 6139 6140 - Support for Python 3.7's builtin ``breakpoint()`` method, see 6141 :ref:`Using the builtin breakpoint function <breakpoint-builtin>` for 6142 details. (:issue:`3180`) 6143 6144 - ``monkeypatch`` now supports a ``context()`` function which acts as a context 6145 manager which undoes all patching done within the ``with`` block. (:issue:`3290`) 6146 6147 - The ``--pdb`` option now causes KeyboardInterrupt to enter the debugger, 6148 instead of stopping the test session. On python 2.7, hitting CTRL+C again 6149 exits the debugger. On python 3.2 and higher, use CTRL+D. (:issue:`3299`) 6150 6151 - pytest no longer changes the log level of the root logger when the 6152 ``log-level`` parameter has greater numeric value than that of the level of 6153 the root logger, which makes it play better with custom logging configuration 6154 in user code. (:issue:`3307`) 6155 6156 6157 Bug Fixes 6158 --------- 6159 6160 - A rare race-condition which might result in corrupted ``.pyc`` files on 6161 Windows has been hopefully solved. (:issue:`3008`) 6162 6163 - Also use iter_marker for discovering the marks applying for marker 6164 expressions from the cli to avoid the bad data from the legacy mark storage. 6165 (:issue:`3441`) 6166 6167 - When showing diffs of failed assertions where the contents contain only 6168 whitespace, escape them using ``repr()`` first to make it easy to spot the 6169 differences. (:issue:`3443`) 6170 6171 6172 Improved Documentation 6173 ---------------------- 6174 6175 - Change documentation copyright year to a range which auto-updates itself each 6176 time it is published. (:issue:`3303`) 6177 6178 6179 Trivial/Internal Changes 6180 ------------------------ 6181 6182 - ``pytest`` now depends on the `python-atomicwrites 6183 <https://github.com/untitaker/python-atomicwrites>`_ library. (:issue:`3008`) 6184 6185 - Update all pypi.python.org URLs to pypi.org. (:issue:`3431`) 6186 6187 - Detect `pytest_` prefixed hooks using the internal plugin manager since 6188 ``pluggy`` is deprecating the ``implprefix`` argument to ``PluginManager``. 6189 (:issue:`3487`) 6190 6191 - Import ``Mapping`` and ``Sequence`` from ``_pytest.compat`` instead of 6192 directly from ``collections`` in ``python_api.py::approx``. Add ``Mapping`` 6193 to ``_pytest.compat``, import it from ``collections`` on python 2, but from 6194 ``collections.abc`` on Python 3 to avoid a ``DeprecationWarning`` on Python 6195 3.7 or newer. (:issue:`3497`) 6196 6197 6198 pytest 3.5.1 (2018-04-23) 6199 ========================= 6200 6201 6202 Bug Fixes 6203 --------- 6204 6205 - Reset ``sys.last_type``, ``sys.last_value`` and ``sys.last_traceback`` before 6206 each test executes. Those attributes are added by pytest during the test run 6207 to aid debugging, but were never reset so they would create a leaking 6208 reference to the last failing test's frame which in turn could never be 6209 reclaimed by the garbage collector. (:issue:`2798`) 6210 6211 - ``pytest.raises`` now raises ``TypeError`` when receiving an unknown keyword 6212 argument. (:issue:`3348`) 6213 6214 - ``pytest.raises`` now works with exception classes that look like iterables. 6215 (:issue:`3372`) 6216 6217 6218 Improved Documentation 6219 ---------------------- 6220 6221 - Fix typo in ``caplog`` fixture documentation, which incorrectly identified 6222 certain attributes as methods. (:issue:`3406`) 6223 6224 6225 Trivial/Internal Changes 6226 ------------------------ 6227 6228 - Added a more indicative error message when parametrizing a function whose 6229 argument takes a default value. (:issue:`3221`) 6230 6231 - Remove internal ``_pytest.terminal.flatten`` function in favor of 6232 ``more_itertools.collapse``. (:issue:`3330`) 6233 6234 - Import some modules from ``collections.abc`` instead of ``collections`` as 6235 the former modules trigger ``DeprecationWarning`` in Python 3.7. (:issue:`3339`) 6236 6237 - record_property is no longer experimental, removing the warnings was 6238 forgotten. (:issue:`3360`) 6239 6240 - Mention in documentation and CLI help that fixtures with leading ``_`` are 6241 printed by ``pytest --fixtures`` only if the ``-v`` option is added. (:issue:`3398`) 6242 6243 6244 pytest 3.5.0 (2018-03-21) 6245 ========================= 6246 6247 Deprecations and Removals 6248 ------------------------- 6249 6250 - ``record_xml_property`` fixture is now deprecated in favor of the more 6251 generic ``record_property``. (:issue:`2770`) 6252 6253 - Defining ``pytest_plugins`` is now deprecated in non-top-level conftest.py 6254 files, because they "leak" to the entire directory tree. 6255 :ref:`See the docs <pytest_plugins in non-top-level conftest files deprecated>` 6256 for the rationale behind this decision (:issue:`3084`) 6257 6258 6259 Features 6260 -------- 6261 6262 - New ``--show-capture`` command-line option that allows to specify how to 6263 display captured output when tests fail: ``no``, ``stdout``, ``stderr``, 6264 ``log`` or ``all`` (the default). (:issue:`1478`) 6265 6266 - New ``--rootdir`` command-line option to override the rules for discovering 6267 the root directory. See :doc:`customize <reference/customize>` in the documentation for 6268 details. (:issue:`1642`) 6269 6270 - Fixtures are now instantiated based on their scopes, with higher-scoped 6271 fixtures (such as ``session``) being instantiated first than lower-scoped 6272 fixtures (such as ``function``). The relative order of fixtures of the same 6273 scope is kept unchanged, based in their declaration order and their 6274 dependencies. (:issue:`2405`) 6275 6276 - ``record_xml_property`` renamed to ``record_property`` and is now compatible 6277 with xdist, markers and any reporter. ``record_xml_property`` name is now 6278 deprecated. (:issue:`2770`) 6279 6280 - New ``--nf``, ``--new-first`` options: run new tests first followed by the 6281 rest of the tests, in both cases tests are also sorted by the file modified 6282 time, with more recent files coming first. (:issue:`3034`) 6283 6284 - New ``--last-failed-no-failures`` command-line option that allows to specify 6285 the behavior of the cache plugin's ```--last-failed`` feature when no tests 6286 failed in the last run (or no cache was found): ``none`` or ``all`` (the 6287 default). (:issue:`3139`) 6288 6289 - New ``--doctest-continue-on-failure`` command-line option to enable doctests 6290 to show multiple failures for each snippet, instead of stopping at the first 6291 failure. (:issue:`3149`) 6292 6293 - Captured log messages are added to the ``<system-out>`` tag in the generated 6294 junit xml file if the ``junit_logging`` ini option is set to ``system-out``. 6295 If the value of this ini option is ``system-err``, the logs are written to 6296 ``<system-err>``. The default value for ``junit_logging`` is ``no``, meaning 6297 captured logs are not written to the output file. (:issue:`3156`) 6298 6299 - Allow the logging plugin to handle ``pytest_runtest_logstart`` and 6300 ``pytest_runtest_logfinish`` hooks when live logs are enabled. (:issue:`3189`) 6301 6302 - Passing ``--log-cli-level`` in the command-line now automatically activates 6303 live logging. (:issue:`3190`) 6304 6305 - Add command line option ``--deselect`` to allow deselection of individual 6306 tests at collection time. (:issue:`3198`) 6307 6308 - Captured logs are printed before entering pdb. (:issue:`3204`) 6309 6310 - Deselected item count is now shown before tests are run, e.g. ``collected X 6311 items / Y deselected``. (:issue:`3213`) 6312 6313 - The builtin module ``platform`` is now available for use in expressions in 6314 ``pytest.mark``. (:issue:`3236`) 6315 6316 - The *short test summary info* section now is displayed after tracebacks and 6317 warnings in the terminal. (:issue:`3255`) 6318 6319 - New ``--verbosity`` flag to set verbosity level explicitly. (:issue:`3296`) 6320 6321 - ``pytest.approx`` now accepts comparing a numpy array with a scalar. (:issue:`3312`) 6322 6323 6324 Bug Fixes 6325 --------- 6326 6327 - Suppress ``IOError`` when closing the temporary file used for capturing 6328 streams in Python 2.7. (:issue:`2370`) 6329 6330 - Fixed ``clear()`` method on ``caplog`` fixture which cleared ``records``, but 6331 not the ``text`` property. (:issue:`3297`) 6332 6333 - During test collection, when stdin is not allowed to be read, the 6334 ``DontReadFromStdin`` object still allow itself to be iterable and resolved 6335 to an iterator without crashing. (:issue:`3314`) 6336 6337 6338 Improved Documentation 6339 ---------------------- 6340 6341 - Added a :doc:`reference <reference/reference>` page 6342 to the docs. (:issue:`1713`) 6343 6344 6345 Trivial/Internal Changes 6346 ------------------------ 6347 6348 - Change minimum requirement of ``attrs`` to ``17.4.0``. (:issue:`3228`) 6349 6350 - Renamed example directories so all tests pass when ran from the base 6351 directory. (:issue:`3245`) 6352 6353 - Internal ``mark.py`` module has been turned into a package. (:issue:`3250`) 6354 6355 - ``pytest`` now depends on the `more-itertools 6356 <https://github.com/erikrose/more-itertools>`_ package. (:issue:`3265`) 6357 6358 - Added warning when ``[pytest]`` section is used in a ``.cfg`` file passed 6359 with ``-c`` (:issue:`3268`) 6360 6361 - ``nodeids`` can now be passed explicitly to ``FSCollector`` and ``Node`` 6362 constructors. (:issue:`3291`) 6363 6364 - Internal refactoring of ``FormattedExcinfo`` to use ``attrs`` facilities and 6365 remove old support code for legacy Python versions. (:issue:`3292`) 6366 6367 - Refactoring to unify how verbosity is handled internally. (:issue:`3296`) 6368 6369 - Internal refactoring to better integrate with argparse. (:issue:`3304`) 6370 6371 - Fix a python example when calling a fixture in doc/en/usage.rst (:issue:`3308`) 6372 6373 6374 pytest 3.4.2 (2018-03-04) 6375 ========================= 6376 6377 Bug Fixes 6378 --------- 6379 6380 - Removed progress information when capture option is ``no``. (:issue:`3203`) 6381 6382 - Refactor check of bindir from ``exists`` to ``isdir``. (:issue:`3241`) 6383 6384 - Fix ``TypeError`` issue when using ``approx`` with a ``Decimal`` value. 6385 (:issue:`3247`) 6386 6387 - Fix reference cycle generated when using the ``request`` fixture. (:issue:`3249`) 6388 6389 - ``[tool:pytest]`` sections in ``*.cfg`` files passed by the ``-c`` option are 6390 now properly recognized. (:issue:`3260`) 6391 6392 6393 Improved Documentation 6394 ---------------------- 6395 6396 - Add logging plugin to plugins list. (:issue:`3209`) 6397 6398 6399 Trivial/Internal Changes 6400 ------------------------ 6401 6402 - Fix minor typo in fixture.rst (:issue:`3259`) 6403 6404 6405 pytest 3.4.1 (2018-02-20) 6406 ========================= 6407 6408 Bug Fixes 6409 --------- 6410 6411 - Move import of ``doctest.UnexpectedException`` to top-level to avoid possible 6412 errors when using ``--pdb``. (:issue:`1810`) 6413 6414 - Added printing of captured stdout/stderr before entering pdb, and improved a 6415 test which was giving false negatives about output capturing. (:issue:`3052`) 6416 6417 - Fix ordering of tests using parametrized fixtures which can lead to fixtures 6418 being created more than necessary. (:issue:`3161`) 6419 6420 - Fix bug where logging happening at hooks outside of "test run" hooks would 6421 cause an internal error. (:issue:`3184`) 6422 6423 - Detect arguments injected by ``unittest.mock.patch`` decorator correctly when 6424 pypi ``mock.patch`` is installed and imported. (:issue:`3206`) 6425 6426 - Errors shown when a ``pytest.raises()`` with ``match=`` fails are now cleaner 6427 on what happened: When no exception was raised, the "matching '...'" part got 6428 removed as it falsely implies that an exception was raised but it didn't 6429 match. When a wrong exception was raised, it's now thrown (like 6430 ``pytest.raised()`` without ``match=`` would) instead of complaining about 6431 the unmatched text. (:issue:`3222`) 6432 6433 - Fixed output capture handling in doctests on macOS. (:issue:`985`) 6434 6435 6436 Improved Documentation 6437 ---------------------- 6438 6439 - Add Sphinx parameter docs for ``match`` and ``message`` args to 6440 ``pytest.raises``. (:issue:`3202`) 6441 6442 6443 Trivial/Internal Changes 6444 ------------------------ 6445 6446 - pytest has changed the publication procedure and is now being published to 6447 PyPI directly from Travis. (:issue:`3060`) 6448 6449 - Rename ``ParameterSet._for_parameterize()`` to ``_for_parametrize()`` in 6450 order to comply with the naming convention. (:issue:`3166`) 6451 6452 - Skip failing pdb/doctest test on mac. (:issue:`985`) 6453 6454 6455 pytest 3.4.0 (2018-01-30) 6456 ========================= 6457 6458 Deprecations and Removals 6459 ------------------------- 6460 6461 - All pytest classes now subclass ``object`` for better Python 2/3 compatibility. 6462 This should not affect user code except in very rare edge cases. (:issue:`2147`) 6463 6464 6465 Features 6466 -------- 6467 6468 - Introduce ``empty_parameter_set_mark`` ini option to select which mark to 6469 apply when ``@pytest.mark.parametrize`` is given an empty set of parameters. 6470 Valid options are ``skip`` (default) and ``xfail``. Note that it is planned 6471 to change the default to ``xfail`` in future releases as this is considered 6472 less error prone. (:issue:`2527`) 6473 6474 - **Incompatible change**: after community feedback the :doc:`logging <how-to/logging>` functionality has 6475 undergone some changes. Please consult the :ref:`logging documentation <log_changes_3_4>` 6476 for details. (:issue:`3013`) 6477 6478 - Console output falls back to "classic" mode when capturing is disabled (``-s``), 6479 otherwise the output gets garbled to the point of being useless. (:issue:`3038`) 6480 6481 - New :hook:`pytest_runtest_logfinish` 6482 hook which is called when a test item has finished executing, analogous to 6483 :hook:`pytest_runtest_logstart`. 6484 (:issue:`3101`) 6485 6486 - Improve performance when collecting tests using many fixtures. (:issue:`3107`) 6487 6488 - New ``caplog.get_records(when)`` method which provides access to the captured 6489 records for the ``"setup"``, ``"call"`` and ``"teardown"`` 6490 testing stages. (:issue:`3117`) 6491 6492 - New fixture ``record_xml_attribute`` that allows modifying and inserting 6493 attributes on the ``<testcase>`` xml node in JUnit reports. (:issue:`3130`) 6494 6495 - The default cache directory has been renamed from ``.cache`` to 6496 ``.pytest_cache`` after community feedback that the name ``.cache`` did not 6497 make it clear that it was used by pytest. (:issue:`3138`) 6498 6499 - Colorize the levelname column in the live-log output. (:issue:`3142`) 6500 6501 6502 Bug Fixes 6503 --------- 6504 6505 - Fix hanging pexpect test on macOS by using flush() instead of wait(). 6506 (:issue:`2022`) 6507 6508 - Fix restoring Python state after in-process pytest runs with the 6509 ``pytester`` plugin; this may break tests using multiple inprocess 6510 pytest runs if later ones depend on earlier ones leaking global interpreter 6511 changes. (:issue:`3016`) 6512 6513 - Fix skipping plugin reporting hook when test aborted before plugin setup 6514 hook. (:issue:`3074`) 6515 6516 - Fix progress percentage reported when tests fail during teardown. (:issue:`3088`) 6517 6518 - **Incompatible change**: ``-o/--override`` option no longer eats all the 6519 remaining options, which can lead to surprising behavior: for example, 6520 ``pytest -o foo=1 /path/to/test.py`` would fail because ``/path/to/test.py`` 6521 would be considered as part of the ``-o`` command-line argument. One 6522 consequence of this is that now multiple configuration overrides need 6523 multiple ``-o`` flags: ``pytest -o foo=1 -o bar=2``. (:issue:`3103`) 6524 6525 6526 Improved Documentation 6527 ---------------------- 6528 6529 - Document hooks (defined with ``historic=True``) which cannot be used with 6530 ``hookwrapper=True``. (:issue:`2423`) 6531 6532 - Clarify that warning capturing doesn't change the warning filter by default. 6533 (:issue:`2457`) 6534 6535 - Clarify a possible confusion when using pytest_fixture_setup with fixture 6536 functions that return None. (:issue:`2698`) 6537 6538 - Fix the wording of a sentence on doctest flags used in pytest. (:issue:`3076`) 6539 6540 - Prefer ``https://*.readthedocs.io`` over ``http://*.rtfd.org`` for links in 6541 the documentation. (:issue:`3092`) 6542 6543 - Improve readability (wording, grammar) of Getting Started guide (:issue:`3131`) 6544 6545 - Added note that calling pytest.main multiple times from the same process is 6546 not recommended because of import caching. (:issue:`3143`) 6547 6548 6549 Trivial/Internal Changes 6550 ------------------------ 6551 6552 - Show a simple and easy error when keyword expressions trigger a syntax error 6553 (for example, ``"-k foo and import"`` will show an error that you cannot use 6554 the ``import`` keyword in expressions). (:issue:`2953`) 6555 6556 - Change parametrized automatic test id generation to use the ``__name__`` 6557 attribute of functions instead of the fallback argument name plus counter. 6558 (:issue:`2976`) 6559 6560 - Replace py.std with stdlib imports. (:issue:`3067`) 6561 6562 - Corrected 'you' to 'your' in logging docs. (:issue:`3129`) 6563 6564 6565 pytest 3.3.2 (2017-12-25) 6566 ========================= 6567 6568 Bug Fixes 6569 --------- 6570 6571 - pytester: ignore files used to obtain current user metadata in the fd leak 6572 detector. (:issue:`2784`) 6573 6574 - Fix **memory leak** where objects returned by fixtures were never destructed 6575 by the garbage collector. (:issue:`2981`) 6576 6577 - Fix conversion of pyargs to filename to not convert symlinks on Python 2. (:issue:`2985`) 6578 6579 - ``PYTEST_DONT_REWRITE`` is now checked for plugins too rather than only for 6580 test modules. (:issue:`2995`) 6581 6582 6583 Improved Documentation 6584 ---------------------- 6585 6586 - Add clarifying note about behavior of multiple parametrized arguments (:issue:`3001`) 6587 6588 6589 Trivial/Internal Changes 6590 ------------------------ 6591 6592 - Code cleanup. (:issue:`3015`, 6593 :issue:`3021`) 6594 6595 - Clean up code by replacing imports and references of ``_ast`` to ``ast``. 6596 (:issue:`3018`) 6597 6598 6599 pytest 3.3.1 (2017-12-05) 6600 ========================= 6601 6602 Bug Fixes 6603 --------- 6604 6605 - Fix issue about ``-p no:<plugin>`` having no effect. (:issue:`2920`) 6606 6607 - Fix regression with warnings that contained non-strings in their arguments in 6608 Python 2. (:issue:`2956`) 6609 6610 - Always escape null bytes when setting ``PYTEST_CURRENT_TEST``. (:issue:`2957`) 6611 6612 - Fix ``ZeroDivisionError`` when using the ``testmon`` plugin when no tests 6613 were actually collected. (:issue:`2971`) 6614 6615 - Bring back ``TerminalReporter.writer`` as an alias to 6616 ``TerminalReporter._tw``. This alias was removed by accident in the ``3.3.0`` 6617 release. (:issue:`2984`) 6618 6619 - The ``pytest-capturelog`` plugin is now also blacklisted, avoiding errors when 6620 running pytest with it still installed. (:issue:`3004`) 6621 6622 6623 Improved Documentation 6624 ---------------------- 6625 6626 - Fix broken link to plugin ``pytest-localserver``. (:issue:`2963`) 6627 6628 6629 Trivial/Internal Changes 6630 ------------------------ 6631 6632 - Update github "bugs" link in ``CONTRIBUTING.rst`` (:issue:`2949`) 6633 6634 6635 pytest 3.3.0 (2017-11-23) 6636 ========================= 6637 6638 Deprecations and Removals 6639 ------------------------- 6640 6641 - pytest no longer supports Python **2.6** and **3.3**. Those Python versions 6642 are EOL for some time now and incur maintenance and compatibility costs on 6643 the pytest core team, and following up with the rest of the community we 6644 decided that they will no longer be supported starting on this version. Users 6645 which still require those versions should pin pytest to ``<3.3``. (:issue:`2812`) 6646 6647 - Remove internal ``_preloadplugins()`` function. This removal is part of the 6648 ``pytest_namespace()`` hook deprecation. (:issue:`2636`) 6649 6650 - Internally change ``CallSpec2`` to have a list of marks instead of a broken 6651 mapping of keywords. This removes the keywords attribute of the internal 6652 ``CallSpec2`` class. (:issue:`2672`) 6653 6654 - Remove ParameterSet.deprecated_arg_dict - its not a public api and the lack 6655 of the underscore was a naming error. (:issue:`2675`) 6656 6657 - Remove the internal multi-typed attribute ``Node._evalskip`` and replace it 6658 with the boolean ``Node._skipped_by_mark``. (:issue:`2767`) 6659 6660 - The ``params`` list passed to ``pytest.fixture`` is now for 6661 all effects considered immutable and frozen at the moment of the ``pytest.fixture`` 6662 call. Previously the list could be changed before the first invocation of the fixture 6663 allowing for a form of dynamic parametrization (for example, updated from command-line options), 6664 but this was an unwanted implementation detail which complicated the internals and prevented 6665 some internal cleanup. See issue :issue:`2959` 6666 for details and a recommended workaround. 6667 6668 Features 6669 -------- 6670 6671 - ``pytest_fixture_post_finalizer`` hook can now receive a ``request`` 6672 argument. (:issue:`2124`) 6673 6674 - Replace the old introspection code in compat.py that determines the available 6675 arguments of fixtures with inspect.signature on Python 3 and 6676 funcsigs.signature on Python 2. This should respect ``__signature__`` 6677 declarations on functions. (:issue:`2267`) 6678 6679 - Report tests with global ``pytestmark`` variable only once. (:issue:`2549`) 6680 6681 - Now pytest displays the total progress percentage while running tests. The 6682 previous output style can be set by configuring the ``console_output_style`` 6683 setting to ``classic``. (:issue:`2657`) 6684 6685 - Match ``warns`` signature to ``raises`` by adding ``match`` keyword. (:issue:`2708`) 6686 6687 - pytest now captures and displays output from the standard ``logging`` module. 6688 The user can control the logging level to be captured by specifying options 6689 in ``pytest.ini``, the command line and also during individual tests using 6690 markers. Also, a ``caplog`` fixture is available that enables users to test 6691 the captured log during specific tests (similar to ``capsys`` for example). 6692 For more information, please see the :doc:`logging docs <how-to/logging>`. This feature was 6693 introduced by merging the popular :pypi:`pytest-catchlog` plugin, thanks to :user:`thisch`. 6694 Be advised that during the merging the 6695 backward compatibility interface with the defunct ``pytest-capturelog`` has 6696 been dropped. (:issue:`2794`) 6697 6698 - Add ``allow_module_level`` kwarg to ``pytest.skip()``, enabling to skip the 6699 whole module. (:issue:`2808`) 6700 6701 - Allow setting ``file_or_dir``, ``-c``, and ``-o`` in PYTEST_ADDOPTS. (:issue:`2824`) 6702 6703 - Return stdout/stderr capture results as a ``namedtuple``, so ``out`` and 6704 ``err`` can be accessed by attribute. (:issue:`2879`) 6705 6706 - Add ``capfdbinary``, a version of ``capfd`` which returns bytes from 6707 ``readouterr()``. (:issue:`2923`) 6708 6709 - Add ``capsysbinary`` a version of ``capsys`` which returns bytes from 6710 ``readouterr()``. (:issue:`2934`) 6711 6712 - Implement feature to skip ``setup.py`` files when run with 6713 ``--doctest-modules``. (:issue:`502`) 6714 6715 6716 Bug Fixes 6717 --------- 6718 6719 - Resume output capturing after ``capsys/capfd.disabled()`` context manager. 6720 (:issue:`1993`) 6721 6722 - ``pytest_fixture_setup`` and ``pytest_fixture_post_finalizer`` hooks are now 6723 called for all ``conftest.py`` files. (:issue:`2124`) 6724 6725 - If an exception happens while loading a plugin, pytest no longer hides the 6726 original traceback. In Python 2 it will show the original traceback with a new 6727 message that explains in which plugin. In Python 3 it will show 2 canonized 6728 exceptions, the original exception while loading the plugin in addition to an 6729 exception that pytest throws about loading a plugin. (:issue:`2491`) 6730 6731 - ``capsys`` and ``capfd`` can now be used by other fixtures. (:issue:`2709`) 6732 6733 - Internal ``pytester`` plugin properly encodes ``bytes`` arguments to 6734 ``utf-8``. (:issue:`2738`) 6735 6736 - ``testdir`` now uses use the same method used by ``tmpdir`` to create its 6737 temporary directory. This changes the final structure of the ``testdir`` 6738 directory slightly, but should not affect usage in normal scenarios and 6739 avoids a number of potential problems. (:issue:`2751`) 6740 6741 - pytest no longer complains about warnings with unicode messages being 6742 non-ascii compatible even for ascii-compatible messages. As a result of this, 6743 warnings with unicode messages are converted first to an ascii representation 6744 for safety. (:issue:`2809`) 6745 6746 - Change return value of pytest command when ``--maxfail`` is reached from 6747 ``2`` (interrupted) to ``1`` (failed). (:issue:`2845`) 6748 6749 - Fix issue in assertion rewriting which could lead it to rewrite modules which 6750 should not be rewritten. (:issue:`2939`) 6751 6752 - Handle marks without description in ``pytest.ini``. (:issue:`2942`) 6753 6754 6755 Trivial/Internal Changes 6756 ------------------------ 6757 6758 - pytest now depends on :pypi:`attrs` for internal 6759 structures to ease code maintainability. (:issue:`2641`) 6760 6761 - Refactored internal Python 2/3 compatibility code to use ``six``. (:issue:`2642`) 6762 6763 - Stop vendoring ``pluggy`` - we're missing out on its latest changes for not 6764 much benefit (:issue:`2719`) 6765 6766 - Internal refactor: simplify ascii string escaping by using the 6767 backslashreplace error handler in newer Python 3 versions. (:issue:`2734`) 6768 6769 - Remove unnecessary mark evaluator in unittest plugin (:issue:`2767`) 6770 6771 - Calls to ``Metafunc.addcall`` now emit a deprecation warning. This function 6772 is scheduled to be removed in ``pytest-4.0``. (:issue:`2876`) 6773 6774 - Internal move of the parameterset extraction to a more maintainable place. 6775 (:issue:`2877`) 6776 6777 - Internal refactoring to simplify scope node lookup. (:issue:`2910`) 6778 6779 - Configure ``pytest`` to prevent pip from installing pytest in unsupported 6780 Python versions. (:issue:`2922`) 6781 6782 6783 pytest 3.2.5 (2017-11-15) 6784 ========================= 6785 6786 Bug Fixes 6787 --------- 6788 6789 - Remove ``py<1.5`` restriction from ``pytest`` as this can cause version 6790 conflicts in some installations. (:issue:`2926`) 6791 6792 6793 pytest 3.2.4 (2017-11-13) 6794 ========================= 6795 6796 Bug Fixes 6797 --------- 6798 6799 - Fix the bug where running with ``--pyargs`` will result in items with 6800 empty ``parent.nodeid`` if run from a different root directory. (:issue:`2775`) 6801 6802 - Fix issue with ``@pytest.parametrize`` if argnames was specified as keyword arguments. 6803 (:issue:`2819`) 6804 6805 - Strip whitespace from marker names when reading them from INI config. (:issue:`2856`) 6806 6807 - Show full context of doctest source in the pytest output, if the line number of 6808 failed example in the docstring is < 9. (:issue:`2882`) 6809 6810 - Match fixture paths against actual path segments in order to avoid matching folders which share a prefix. 6811 (:issue:`2836`) 6812 6813 Improved Documentation 6814 ---------------------- 6815 6816 - Introduce a dedicated section about conftest.py. (:issue:`1505`) 6817 6818 - Explicitly mention ``xpass`` in the documentation of ``xfail``. (:issue:`1997`) 6819 6820 - Append example for pytest.param in the example/parametrize document. (:issue:`2658`) 6821 6822 - Clarify language of proposal for fixtures parameters (:issue:`2893`) 6823 6824 - List python 3.6 in the documented supported versions in the getting started 6825 document. (:issue:`2903`) 6826 6827 - Clarify the documentation of available fixture scopes. (:issue:`538`) 6828 6829 - Add documentation about the ``python -m pytest`` invocation adding the 6830 current directory to sys.path. (:issue:`911`) 6831 6832 6833 pytest 3.2.3 (2017-10-03) 6834 ========================= 6835 6836 Bug Fixes 6837 --------- 6838 6839 - Fix crash in tab completion when no prefix is given. (:issue:`2748`) 6840 6841 - The equality checking function (``__eq__``) of ``MarkDecorator`` returns 6842 ``False`` if one object is not an instance of ``MarkDecorator``. (:issue:`2758`) 6843 6844 - When running ``pytest --fixtures-per-test``: don't crash if an item has no 6845 _fixtureinfo attribute (e.g. doctests) (:issue:`2788`) 6846 6847 6848 Improved Documentation 6849 ---------------------- 6850 6851 - In help text of ``-k`` option, add example of using ``not`` to not select 6852 certain tests whose names match the provided expression. (:issue:`1442`) 6853 6854 - Add note in ``parametrize.rst`` about calling ``metafunc.parametrize`` 6855 multiple times. (:issue:`1548`) 6856 6857 6858 Trivial/Internal Changes 6859 ------------------------ 6860 6861 - Set ``xfail_strict=True`` in pytest's own test suite to catch expected 6862 failures as soon as they start to pass. (:issue:`2722`) 6863 6864 - Fix typo in example of passing a callable to markers (in example/markers.rst) 6865 (:issue:`2765`) 6866 6867 6868 pytest 3.2.2 (2017-09-06) 6869 ========================= 6870 6871 Bug Fixes 6872 --------- 6873 6874 - Calling the deprecated ``request.getfuncargvalue()`` now shows the source of 6875 the call. (:issue:`2681`) 6876 6877 - Allow tests declared as ``@staticmethod`` to use fixtures. (:issue:`2699`) 6878 6879 - Fixed edge-case during collection: attributes which raised ``pytest.fail`` 6880 when accessed would abort the entire collection. (:issue:`2707`) 6881 6882 - Fix ``ReprFuncArgs`` with mixed unicode and UTF-8 args. (:issue:`2731`) 6883 6884 6885 Improved Documentation 6886 ---------------------- 6887 6888 - In examples on working with custom markers, add examples demonstrating the 6889 usage of ``pytest.mark.MARKER_NAME.with_args`` in comparison with 6890 ``pytest.mark.MARKER_NAME.__call__`` (:issue:`2604`) 6891 6892 - In one of the simple examples, use ``pytest_collection_modifyitems()`` to skip 6893 tests based on a command-line option, allowing its sharing while preventing a 6894 user error when accessing ``pytest.config`` before the argument parsing. 6895 (:issue:`2653`) 6896 6897 6898 Trivial/Internal Changes 6899 ------------------------ 6900 6901 - Fixed minor error in 'Good Practices/Manual Integration' code snippet. 6902 (:issue:`2691`) 6903 6904 - Fixed typo in goodpractices.rst. (:issue:`2721`) 6905 6906 - Improve user guidance regarding ``--resultlog`` deprecation. (:issue:`2739`) 6907 6908 6909 pytest 3.2.1 (2017-08-08) 6910 ========================= 6911 6912 Bug Fixes 6913 --------- 6914 6915 - Fixed small terminal glitch when collecting a single test item. (:issue:`2579`) 6916 6917 - Correctly consider ``/`` as the file separator to automatically mark plugin 6918 files for rewrite on Windows. (:issue:`2591`) 6919 6920 - Properly escape test names when setting ``PYTEST_CURRENT_TEST`` environment 6921 variable. (:issue:`2644`) 6922 6923 - Fix error on Windows and Python 3.6+ when ``sys.stdout`` has been replaced 6924 with a stream-like object which does not implement the full ``io`` module 6925 buffer protocol. In particular this affects ``pytest-xdist`` users on the 6926 aforementioned platform. (:issue:`2666`) 6927 6928 6929 Improved Documentation 6930 ---------------------- 6931 6932 - Explicitly document which pytest features work with ``unittest``. (:issue:`2626`) 6933 6934 6935 pytest 3.2.0 (2017-07-30) 6936 ========================= 6937 6938 Deprecations and Removals 6939 ------------------------- 6940 6941 - ``pytest.approx`` no longer supports ``>``, ``>=``, ``<`` and ``<=`` 6942 operators to avoid surprising/inconsistent behavior. See the :func:`~pytest.approx` docs for more 6943 information. (:issue:`2003`) 6944 6945 - All old-style specific behavior in current classes in the pytest's API is 6946 considered deprecated at this point and will be removed in a future release. 6947 This affects Python 2 users only and in rare situations. (:issue:`2147`) 6948 6949 - A deprecation warning is now raised when using marks for parameters 6950 in ``pytest.mark.parametrize``. Use ``pytest.param`` to apply marks to 6951 parameters instead. (:issue:`2427`) 6952 6953 6954 Features 6955 -------- 6956 6957 - Add support for numpy arrays (and dicts) to approx. (:issue:`1994`) 6958 6959 - Now test function objects have a ``pytestmark`` attribute containing a list 6960 of marks applied directly to the test function, as opposed to marks inherited 6961 from parent classes or modules. (:issue:`2516`) 6962 6963 - Collection ignores local virtualenvs by default; ``--collect-in-virtualenv`` 6964 overrides this behavior. (:issue:`2518`) 6965 6966 - Allow class methods decorated as ``@staticmethod`` to be candidates for 6967 collection as a test function. (Only for Python 2.7 and above. Python 2.6 6968 will still ignore static methods.) (:issue:`2528`) 6969 6970 - Introduce ``mark.with_args`` in order to allow passing functions/classes as 6971 sole argument to marks. (:issue:`2540`) 6972 6973 - New ``cache_dir`` ini option: sets the directory where the contents of the 6974 cache plugin are stored. Directory may be relative or absolute path: if relative path, then 6975 directory is created relative to ``rootdir``, otherwise it is used as is. 6976 Additionally path may contain environment variables which are expanded during 6977 runtime. (:issue:`2543`) 6978 6979 - Introduce the ``PYTEST_CURRENT_TEST`` environment variable that is set with 6980 the ``nodeid`` and stage (``setup``, ``call`` and ``teardown``) of the test 6981 being currently executed. See the :ref:`documentation <pytest current test env>` 6982 for more info. (:issue:`2583`) 6983 6984 - Introduced ``@pytest.mark.filterwarnings`` mark which allows overwriting the 6985 warnings filter on a per test, class or module level. See the :ref:`docs <filterwarnings>` 6986 for more information. (:issue:`2598`) 6987 6988 - ``--last-failed`` now remembers forever when a test has failed and only 6989 forgets it if it passes again. This makes it easy to fix a test suite by 6990 selectively running files and fixing tests incrementally. (:issue:`2621`) 6991 6992 - New ``pytest_report_collectionfinish`` hook which allows plugins to add 6993 messages to the terminal reporting after collection has been finished 6994 successfully. (:issue:`2622`) 6995 6996 - Added support for :pep:`415`\'s 6997 ``Exception.__suppress_context__``. Now if a ``raise exception from None`` is 6998 caught by pytest, pytest will no longer chain the context in the test report. 6999 The behavior now matches Python's traceback behavior. (:issue:`2631`) 7000 7001 - Exceptions raised by ``pytest.fail``, ``pytest.skip`` and ``pytest.xfail`` 7002 now subclass BaseException, making them harder to be caught unintentionally 7003 by normal code. (:issue:`580`) 7004 7005 7006 Bug Fixes 7007 --------- 7008 7009 - Set ``stdin`` to a closed ``PIPE`` in ``pytester.py.Testdir.popen()`` for 7010 avoid unwanted interactive ``pdb`` (:issue:`2023`) 7011 7012 - Add missing ``encoding`` attribute to ``sys.std*`` streams when using 7013 ``capsys`` capture mode. (:issue:`2375`) 7014 7015 - Fix terminal color changing to black on Windows if ``colorama`` is imported 7016 in a ``conftest.py`` file. (:issue:`2510`) 7017 7018 - Fix line number when reporting summary of skipped tests. (:issue:`2548`) 7019 7020 - capture: ensure that EncodedFile.name is a string. (:issue:`2555`) 7021 7022 - The options ``--fixtures`` and ``--fixtures-per-test`` will now keep 7023 indentation within docstrings. (:issue:`2574`) 7024 7025 - doctests line numbers are now reported correctly, fixing `pytest-sugar#122 7026 <https://github.com/Frozenball/pytest-sugar/issues/122>`_. (:issue:`2610`) 7027 7028 - Fix non-determinism in order of fixture collection. Adds new dependency 7029 (ordereddict) for Python 2.6. (:issue:`920`) 7030 7031 7032 Improved Documentation 7033 ---------------------- 7034 7035 - Clarify ``pytest_configure`` hook call order. (:issue:`2539`) 7036 7037 - Extend documentation for testing plugin code with the ``pytester`` plugin. 7038 (:issue:`971`) 7039 7040 7041 Trivial/Internal Changes 7042 ------------------------ 7043 7044 - Update help message for ``--strict`` to make it clear it only deals with 7045 unregistered markers, not warnings. (:issue:`2444`) 7046 7047 - Internal code move: move code for pytest.approx/pytest.raises to own files in 7048 order to cut down the size of python.py (:issue:`2489`) 7049 7050 - Renamed the utility function ``_pytest.compat._escape_strings`` to 7051 ``_ascii_escaped`` to better communicate the function's purpose. (:issue:`2533`) 7052 7053 - Improve error message for CollectError with skip/skipif. (:issue:`2546`) 7054 7055 - Emit warning about ``yield`` tests being deprecated only once per generator. 7056 (:issue:`2562`) 7057 7058 - Ensure final collected line doesn't include artifacts of previous write. 7059 (:issue:`2571`) 7060 7061 - Fixed all flake8 errors and warnings. (:issue:`2581`) 7062 7063 - Added ``fix-lint`` tox environment to run automatic pep8 fixes on the code. 7064 (:issue:`2582`) 7065 7066 - Turn warnings into errors in pytest's own test suite in order to catch 7067 regressions due to deprecations more promptly. (:issue:`2588`) 7068 7069 - Show multiple issue links in CHANGELOG entries. (:issue:`2620`) 7070 7071 7072 pytest 3.1.3 (2017-07-03) 7073 ========================= 7074 7075 Bug Fixes 7076 --------- 7077 7078 - Fix decode error in Python 2 for doctests in docstrings. (:issue:`2434`) 7079 7080 - Exceptions raised during teardown by finalizers are now suppressed until all 7081 finalizers are called, with the initial exception reraised. (:issue:`2440`) 7082 7083 - Fix incorrect "collected items" report when specifying tests on the command- 7084 line. (:issue:`2464`) 7085 7086 - ``deprecated_call`` in context-manager form now captures deprecation warnings 7087 even if the same warning has already been raised. Also, ``deprecated_call`` 7088 will always produce the same error message (previously it would produce 7089 different messages in context-manager vs. function-call mode). (:issue:`2469`) 7090 7091 - Fix issue where paths collected by pytest could have triple leading ``/`` 7092 characters. (:issue:`2475`) 7093 7094 - Fix internal error when trying to detect the start of a recursive traceback. 7095 (:issue:`2486`) 7096 7097 7098 Improved Documentation 7099 ---------------------- 7100 7101 - Explicitly state for which hooks the calls stop after the first non-None 7102 result. (:issue:`2493`) 7103 7104 7105 Trivial/Internal Changes 7106 ------------------------ 7107 7108 - Create invoke tasks for updating the vendored packages. (:issue:`2474`) 7109 7110 - Update copyright dates in LICENSE, README.rst and in the documentation. 7111 (:issue:`2499`) 7112 7113 7114 pytest 3.1.2 (2017-06-08) 7115 ========================= 7116 7117 Bug Fixes 7118 --------- 7119 7120 - Required options added via ``pytest_addoption`` will no longer prevent using 7121 --help without passing them. (#1999) 7122 7123 - Respect ``python_files`` in assertion rewriting. (#2121) 7124 7125 - Fix recursion error detection when frames in the traceback contain objects 7126 that can't be compared (like ``numpy`` arrays). (#2459) 7127 7128 - ``UnicodeWarning`` is issued from the internal pytest warnings plugin only 7129 when the message contains non-ascii unicode (Python 2 only). (#2463) 7130 7131 - Added a workaround for Python 3.6 ``WindowsConsoleIO`` breaking due to Pytests's 7132 ``FDCapture``. Other code using console handles might still be affected by the 7133 very same issue and might require further workarounds/fixes, i.e. ``colorama``. 7134 (#2467) 7135 7136 7137 Improved Documentation 7138 ---------------------- 7139 7140 - Fix internal API links to ``pluggy`` objects. (#2331) 7141 7142 - Make it clear that ``pytest.xfail`` stops test execution at the calling point 7143 and improve overall flow of the ``skipping`` docs. (#810) 7144 7145 7146 pytest 3.1.1 (2017-05-30) 7147 ========================= 7148 7149 Bug Fixes 7150 --------- 7151 7152 - pytest warning capture no longer overrides existing warning filters. The 7153 previous behaviour would override all filters and caused regressions in test 7154 suites which configure warning filters to match their needs. Note that as a 7155 side-effect of this is that ``DeprecationWarning`` and 7156 ``PendingDeprecationWarning`` are no longer shown by default. (#2430) 7157 7158 - Fix issue with non-ascii contents in doctest text files. (#2434) 7159 7160 - Fix encoding errors for unicode warnings in Python 2. (#2436) 7161 7162 - ``pytest.deprecated_call`` now captures ``PendingDeprecationWarning`` in 7163 context manager form. (#2441) 7164 7165 7166 Improved Documentation 7167 ---------------------- 7168 7169 - Addition of towncrier for changelog management. (#2390) 7170 7171 7172 3.1.0 (2017-05-22) 7173 ================== 7174 7175 7176 New Features 7177 ------------ 7178 7179 * The ``pytest-warnings`` plugin has been integrated into the core and now ``pytest`` automatically 7180 captures and displays warnings at the end of the test session. 7181 7182 .. warning:: 7183 7184 This feature may disrupt test suites which apply and treat warnings themselves, and can be 7185 disabled in your ``pytest.ini``: 7186 7187 .. code-block:: ini 7188 7189 [pytest] 7190 addopts = -p no:warnings 7191 7192 See the :doc:`warnings documentation page <how-to/capture-warnings>` for more 7193 information. 7194 7195 Thanks :user:`nicoddemus` for the PR. 7196 7197 * Added ``junit_suite_name`` ini option to specify root ``<testsuite>`` name for JUnit XML reports (:issue:`533`). 7198 7199 * Added an ini option ``doctest_encoding`` to specify which encoding to use for doctest files. 7200 Thanks :user:`wheerd` for the PR (:pull:`2101`). 7201 7202 * ``pytest.warns`` now checks for subclass relationship rather than 7203 class equality. Thanks :user:`lesteve` for the PR (:pull:`2166`) 7204 7205 * ``pytest.raises`` now asserts that the error message matches a text or regex 7206 with the ``match`` keyword argument. Thanks :user:`Kriechi` for the PR. 7207 7208 * ``pytest.param`` can be used to declare test parameter sets with marks and test ids. 7209 Thanks :user:`RonnyPfannschmidt` for the PR. 7210 7211 7212 Changes 7213 ------- 7214 7215 * remove all internal uses of pytest_namespace hooks, 7216 this is to prepare the removal of preloadconfig in pytest 4.0 7217 Thanks to :user:`RonnyPfannschmidt` for the PR. 7218 7219 * pytest now warns when a callable ids raises in a parametrized test. Thanks :user:`fogo` for the PR. 7220 7221 * It is now possible to skip test classes from being collected by setting a 7222 ``__test__`` attribute to ``False`` in the class body (:issue:`2007`). Thanks 7223 to :user:`syre` for the report and :user:`lwm` for the PR. 7224 7225 * Change junitxml.py to produce reports that comply with Junitxml schema. 7226 If the same test fails with failure in call and then errors in teardown 7227 we split testcase element into two, one containing the error and the other 7228 the failure. (:issue:`2228`) Thanks to :user:`kkoukiou` for the PR. 7229 7230 * Testcase reports with a ``url`` attribute will now properly write this to junitxml. 7231 Thanks :user:`fushi` for the PR (:pull:`1874`). 7232 7233 * Remove common items from dict comparison output when verbosity=1. Also update 7234 the truncation message to make it clearer that pytest truncates all 7235 assertion messages if verbosity < 2 (:issue:`1512`). 7236 Thanks :user:`mattduck` for the PR 7237 7238 * ``--pdbcls`` no longer implies ``--pdb``. This makes it possible to use 7239 ``addopts=--pdbcls=module.SomeClass`` on ``pytest.ini``. Thanks :user:`davidszotten` for 7240 the PR (:pull:`1952`). 7241 7242 * fix :issue:`2013`: turn RecordedWarning into ``namedtuple``, 7243 to give it a comprehensible repr while preventing unwarranted modification. 7244 7245 * fix :issue:`2208`: ensure an iteration limit for ``_pytest.compat.get_real_func``. 7246 Thanks :user:`RonnyPfannschmidt` for the report and PR. 7247 7248 * Hooks are now verified after collection is complete, rather than right after loading installed plugins. This 7249 makes it easy to write hooks for plugins which will be loaded during collection, for example using the 7250 ``pytest_plugins`` special variable (:issue:`1821`). 7251 Thanks :user:`nicoddemus` for the PR. 7252 7253 * Modify ``pytest_make_parametrize_id()`` hook to accept ``argname`` as an 7254 additional parameter. 7255 Thanks :user:`unsignedint` for the PR. 7256 7257 * Add ``venv`` to the default ``norecursedirs`` setting. 7258 Thanks :user:`The-Compiler` for the PR. 7259 7260 * ``PluginManager.import_plugin`` now accepts unicode plugin names in Python 2. 7261 Thanks :user:`reutsharabani` for the PR. 7262 7263 * fix :issue:`2308`: When using both ``--lf`` and ``--ff``, only the last failed tests are run. 7264 Thanks :user:`ojii` for the PR. 7265 7266 * Replace minor/patch level version numbers in the documentation with placeholders. 7267 This significantly reduces change-noise as different contributors regenerate 7268 the documentation on different platforms. 7269 Thanks :user:`RonnyPfannschmidt` for the PR. 7270 7271 * fix :issue:`2391`: consider pytest_plugins on all plugin modules 7272 Thanks :user:`RonnyPfannschmidt` for the PR. 7273 7274 7275 Bug Fixes 7276 --------- 7277 7278 * Fix ``AttributeError`` on ``sys.stdout.buffer`` / ``sys.stderr.buffer`` 7279 while using ``capsys`` fixture in python 3. (:issue:`1407`). 7280 Thanks to :user:`asottile`. 7281 7282 * Change capture.py's ``DontReadFromInput`` class to throw ``io.UnsupportedOperation`` errors rather 7283 than ValueErrors in the ``fileno`` method (:issue:`2276`). 7284 Thanks :user:`metasyn` and :user:`vlad-dragos` for the PR. 7285 7286 * Fix exception formatting while importing modules when the exception message 7287 contains non-ascii characters (:issue:`2336`). 7288 Thanks :user:`fabioz` for the report and :user:`nicoddemus` for the PR. 7289 7290 * Added documentation related to issue (:issue:`1937`) 7291 Thanks :user:`skylarjhdownes` for the PR. 7292 7293 * Allow collecting files with any file extension as Python modules (:issue:`2369`). 7294 Thanks :user:`Kodiologist` for the PR. 7295 7296 * Show the correct error message when collect "parametrize" func with wrong args (:issue:`2383`). 7297 Thanks :user:`The-Compiler` for the report and :user:`robin0371` for the PR. 7298 7299 7300 3.0.7 (2017-03-14) 7301 ================== 7302 7303 7304 * Fix issue in assertion rewriting breaking due to modules silently discarding 7305 other modules when importing fails 7306 Notably, importing the ``anydbm`` module is fixed. (:issue:`2248`). 7307 Thanks :user:`pfhayes` for the PR. 7308 7309 * junitxml: Fix problematic case where system-out tag occurred twice per testcase 7310 element in the XML report. Thanks :user:`kkoukiou` for the PR. 7311 7312 * Fix regression, pytest now skips unittest correctly if run with ``--pdb`` 7313 (:issue:`2137`). Thanks to :user:`gst` for the report and :user:`mbyt` for the PR. 7314 7315 * Ignore exceptions raised from descriptors (e.g. properties) during Python test collection (:issue:`2234`). 7316 Thanks to :user:`bluetech`. 7317 7318 * ``--override-ini`` now correctly overrides some fundamental options like ``python_files`` (:issue:`2238`). 7319 Thanks :user:`sirex` for the report and :user:`nicoddemus` for the PR. 7320 7321 * Replace ``raise StopIteration`` usages in the code by simple ``returns`` to finish generators, in accordance to :pep:`479` (:issue:`2160`). 7322 Thanks to :user:`nicoddemus` for the PR. 7323 7324 * Fix internal errors when an unprintable ``AssertionError`` is raised inside a test. 7325 Thanks :user:`omerhadari` for the PR. 7326 7327 * Skipping plugin now also works with test items generated by custom collectors (:issue:`2231`). 7328 Thanks to :user:`vidartf`. 7329 7330 * Fix trailing whitespace in console output if no .ini file presented (:issue:`2281`). Thanks :user:`fbjorn` for the PR. 7331 7332 * Conditionless ``xfail`` markers no longer rely on the underlying test item 7333 being an instance of ``PyobjMixin``, and can therefore apply to tests not 7334 collected by the built-in python test collector. Thanks :user:`barneygale` for the 7335 PR. 7336 7337 7338 3.0.6 (2017-01-22) 7339 ================== 7340 7341 * pytest no longer generates ``PendingDeprecationWarning`` from its own operations, which was introduced by mistake in version ``3.0.5`` (:issue:`2118`). 7342 Thanks to :user:`nicoddemus` for the report and :user:`RonnyPfannschmidt` for the PR. 7343 7344 7345 * pytest no longer recognizes coroutine functions as yield tests (:issue:`2129`). 7346 Thanks to :user:`malinoff` for the PR. 7347 7348 * Plugins loaded by the ``PYTEST_PLUGINS`` environment variable are now automatically 7349 considered for assertion rewriting (:issue:`2185`). 7350 Thanks :user:`nicoddemus` for the PR. 7351 7352 * Improve error message when pytest.warns fails (:issue:`2150`). The type(s) of the 7353 expected warnings and the list of caught warnings is added to the 7354 error message. Thanks :user:`lesteve` for the PR. 7355 7356 * Fix ``pytester`` internal plugin to work correctly with latest versions of 7357 ``zope.interface`` (:issue:`1989`). Thanks :user:`nicoddemus` for the PR. 7358 7359 * Assert statements of the ``pytester`` plugin again benefit from assertion rewriting (:issue:`1920`). 7360 Thanks :user:`RonnyPfannschmidt` for the report and :user:`nicoddemus` for the PR. 7361 7362 * Specifying tests with colons like ``test_foo.py::test_bar`` for tests in 7363 subdirectories with ini configuration files now uses the correct ini file 7364 (:issue:`2148`). Thanks :user:`pelme`. 7365 7366 * Fail ``testdir.runpytest().assert_outcomes()`` explicitly if the pytest 7367 terminal output it relies on is missing. Thanks to :user:`eli-b` for the PR. 7368 7369 7370 3.0.5 (2016-12-05) 7371 ================== 7372 7373 * Add warning when not passing ``option=value`` correctly to ``-o/--override-ini`` (:issue:`2105`). 7374 Also improved the help documentation. Thanks to :user:`mbukatov` for the report and 7375 :user:`lwm` for the PR. 7376 7377 * Now ``--confcutdir`` and ``--junit-xml`` are properly validated if they are directories 7378 and filenames, respectively (:issue:`2089` and :issue:`2078`). Thanks to :user:`lwm` for the PR. 7379 7380 * Add hint to error message hinting possible missing ``__init__.py`` (:issue:`478`). Thanks :user:`DuncanBetts`. 7381 7382 * More accurately describe when fixture finalization occurs in documentation (:issue:`687`). Thanks :user:`DuncanBetts`. 7383 7384 * Provide ``:ref:`` targets for ``recwarn.rst`` so we can use intersphinx referencing. 7385 Thanks to :user:`dupuy` for the report and :user:`lwm` for the PR. 7386 7387 * In Python 2, use a simple ``+-`` ASCII string in the string representation of ``pytest.approx`` (for example ``"4 +- 4.0e-06"``) 7388 because it is brittle to handle that in different contexts and representations internally in pytest 7389 which can result in bugs such as :issue:`2111`. In Python 3, the representation still uses ``±`` (for example ``4 ± 4.0e-06``). 7390 Thanks :user:`kerrick-lyft` for the report and :user:`nicoddemus` for the PR. 7391 7392 * Using ``item.Function``, ``item.Module``, etc., is now issuing deprecation warnings, prefer 7393 ``pytest.Function``, ``pytest.Module``, etc., instead (:issue:`2034`). 7394 Thanks :user:`nmundar` for the PR. 7395 7396 * Fix error message using ``approx`` with complex numbers (:issue:`2082`). 7397 Thanks :user:`adler-j` for the report and :user:`nicoddemus` for the PR. 7398 7399 * Fixed false-positives warnings from assertion rewrite hook for modules imported more than 7400 once by the ``pytest_plugins`` mechanism. 7401 Thanks :user:`nicoddemus` for the PR. 7402 7403 * Remove an internal cache which could cause hooks from ``conftest.py`` files in 7404 sub-directories to be called in other directories incorrectly (:issue:`2016`). 7405 Thanks :user:`d-b-w` for the report and :user:`nicoddemus` for the PR. 7406 7407 * Remove internal code meant to support earlier Python 3 versions that produced the side effect 7408 of leaving ``None`` in ``sys.modules`` when expressions were evaluated by pytest (for example passing a condition 7409 as a string to ``pytest.mark.skipif``)(:issue:`2103`). 7410 Thanks :user:`jaraco` for the report and :user:`nicoddemus` for the PR. 7411 7412 * Cope gracefully with a .pyc file with no matching .py file (:issue:`2038`). Thanks 7413 :user:`nedbat`. 7414 7415 7416 3.0.4 (2016-11-09) 7417 ================== 7418 7419 * Import errors when collecting test modules now display the full traceback (:issue:`1976`). 7420 Thanks :user:`cwitty` for the report and :user:`nicoddemus` for the PR. 7421 7422 * Fix confusing command-line help message for custom options with two or more ``metavar`` properties (:issue:`2004`). 7423 Thanks :user:`okulynyak` and :user:`davehunt` for the report and :user:`nicoddemus` for the PR. 7424 7425 * When loading plugins, import errors which contain non-ascii messages are now properly handled in Python 2 (:issue:`1998`). 7426 Thanks :user:`nicoddemus` for the PR. 7427 7428 * Fixed cyclic reference when ``pytest.raises`` is used in context-manager form (:issue:`1965`). Also as a 7429 result of this fix, ``sys.exc_info()`` is left empty in both context-manager and function call usages. 7430 Previously, ``sys.exc_info`` would contain the exception caught by the context manager, 7431 even when the expected exception occurred. 7432 Thanks :user:`MSeifert04` for the report and the PR. 7433 7434 * Fixed false-positives warnings from assertion rewrite hook for modules that were rewritten but 7435 were later marked explicitly by ``pytest.register_assert_rewrite`` 7436 or implicitly as a plugin (:issue:`2005`). 7437 Thanks :user:`RonnyPfannschmidt` for the report and :user:`nicoddemus` for the PR. 7438 7439 * Report teardown output on test failure (:issue:`442`). 7440 Thanks :user:`matclab` for the PR. 7441 7442 * Fix teardown error message in generated xUnit XML. 7443 Thanks :user:`gdyuldin` for the PR. 7444 7445 * Properly handle exceptions in ``multiprocessing`` tasks (:issue:`1984`). 7446 Thanks :user:`adborden` for the report and :user:`nicoddemus` for the PR. 7447 7448 * Clean up unittest TestCase objects after tests are complete (:issue:`1649`). 7449 Thanks :user:`d-b-w` for the report and PR. 7450 7451 7452 3.0.3 (2016-09-28) 7453 ================== 7454 7455 * The ``ids`` argument to ``parametrize`` again accepts ``unicode`` strings 7456 in Python 2 (:issue:`1905`). 7457 Thanks :user:`philpep` for the report and :user:`nicoddemus` for the PR. 7458 7459 * Assertions are now being rewritten for plugins in development mode 7460 (``pip install -e``) (:issue:`1934`). 7461 Thanks :user:`nicoddemus` for the PR. 7462 7463 * Fix pkg_resources import error in Jython projects (:issue:`1853`). 7464 Thanks :user:`raquelalegre` for the PR. 7465 7466 * Got rid of ``AttributeError: 'Module' object has no attribute '_obj'`` exception 7467 in Python 3 (:issue:`1944`). 7468 Thanks :user:`axil` for the PR. 7469 7470 * Explain a bad scope value passed to ``@fixture`` declarations or 7471 a ``MetaFunc.parametrize()`` call. 7472 7473 * This version includes ``pluggy-0.4.0``, which correctly handles 7474 ``VersionConflict`` errors in plugins (:issue:`704`). 7475 Thanks :user:`nicoddemus` for the PR. 7476 7477 7478 3.0.2 (2016-09-01) 7479 ================== 7480 7481 * Improve error message when passing non-string ids to ``pytest.mark.parametrize`` (:issue:`1857`). 7482 Thanks :user:`okken` for the report and :user:`nicoddemus` for the PR. 7483 7484 * Add ``buffer`` attribute to stdin stub class ``pytest.capture.DontReadFromInput`` 7485 Thanks :user:`joguSD` for the PR. 7486 7487 * Fix ``UnicodeEncodeError`` when string comparison with unicode has failed. (:issue:`1864`) 7488 Thanks :user:`AiOO` for the PR. 7489 7490 * ``pytest_plugins`` is now handled correctly if defined as a string (as opposed as 7491 a sequence of strings) when modules are considered for assertion rewriting. 7492 Due to this bug, much more modules were being rewritten than necessary 7493 if a test suite uses ``pytest_plugins`` to load internal plugins (:issue:`1888`). 7494 Thanks :user:`jaraco` for the report and :user:`nicoddemus` for the PR (:pull:`1891`). 7495 7496 * Do not call tearDown and cleanups when running tests from 7497 ``unittest.TestCase`` subclasses with ``--pdb`` 7498 enabled. This allows proper post mortem debugging for all applications 7499 which have significant logic in their tearDown machinery (:issue:`1890`). Thanks 7500 :user:`mbyt` for the PR. 7501 7502 * Fix use of deprecated ``getfuncargvalue`` method in the internal doctest plugin. 7503 Thanks :user:`ViviCoder` for the report (:issue:`1898`). 7504 7505 7506 3.0.1 (2016-08-23) 7507 ================== 7508 7509 * Fix regression when ``importorskip`` is used at module level (:issue:`1822`). 7510 Thanks :user:`jaraco` and :user:`The-Compiler` for the report and :user:`nicoddemus` for the PR. 7511 7512 * Fix parametrization scope when session fixtures are used in conjunction 7513 with normal parameters in the same call (:issue:`1832`). 7514 Thanks :user:`The-Compiler` for the report, :user:`Kingdread` and :user:`nicoddemus` for the PR. 7515 7516 * Fix internal error when parametrizing tests or fixtures using an empty ``ids`` argument (:issue:`1849`). 7517 Thanks :user:`OPpuolitaival` for the report and :user:`nicoddemus` for the PR. 7518 7519 * Fix loader error when running ``pytest`` embedded in a zipfile. 7520 Thanks :user:`mbachry` for the PR. 7521 7522 7523 .. _release-3.0.0: 7524 7525 3.0.0 (2016-08-18) 7526 ================== 7527 7528 **Incompatible changes** 7529 7530 7531 A number of incompatible changes were made in this release, with the intent of removing features deprecated for a long 7532 time or change existing behaviors in order to make them less surprising/more useful. 7533 7534 * Reinterpretation mode has now been removed. Only plain and rewrite 7535 mode are available, consequently the ``--assert=reinterp`` option is 7536 no longer available. This also means files imported from plugins or 7537 ``conftest.py`` will not benefit from improved assertions by 7538 default, you should use ``pytest.register_assert_rewrite()`` to 7539 explicitly turn on assertion rewriting for those files. Thanks 7540 :user:`flub` for the PR. 7541 7542 * The following deprecated commandline options were removed: 7543 7544 * ``--genscript``: no longer supported; 7545 * ``--no-assert``: use ``--assert=plain`` instead; 7546 * ``--nomagic``: use ``--assert=plain`` instead; 7547 * ``--report``: use ``-r`` instead; 7548 7549 Thanks to :user:`RedBeardCode` for the PR (:pull:`1664`). 7550 7551 * ImportErrors in plugins now are a fatal error instead of issuing a 7552 pytest warning (:issue:`1479`). Thanks to :user:`The-Compiler` for the PR. 7553 7554 * Removed support code for Python 3 versions < 3.3 (:pull:`1627`). 7555 7556 * Removed all ``py.test-X*`` entry points. The versioned, suffixed entry points 7557 were never documented and a leftover from a pre-virtualenv era. These entry 7558 points also created broken entry points in wheels, so removing them also 7559 removes a source of confusion for users (:issue:`1632`). 7560 Thanks :user:`obestwalter` for the PR. 7561 7562 * ``pytest.skip()`` now raises an error when used to decorate a test function, 7563 as opposed to its original intent (to imperatively skip a test inside a test function). Previously 7564 this usage would cause the entire module to be skipped (:issue:`607`). 7565 Thanks :user:`omarkohl` for the complete PR (:pull:`1519`). 7566 7567 * Exit tests if a collection error occurs. A poll indicated most users will hit CTRL-C 7568 anyway as soon as they see collection errors, so pytest might as well make that the default behavior (:issue:`1421`). 7569 A ``--continue-on-collection-errors`` option has been added to restore the previous behaviour. 7570 Thanks :user:`olegpidsadnyi` and :user:`omarkohl` for the complete PR (:pull:`1628`). 7571 7572 * Renamed the pytest ``pdb`` module (plugin) into ``debugging`` to avoid clashes with the builtin ``pdb`` module. 7573 7574 * Raise a helpful failure message when requesting a parametrized fixture at runtime, 7575 e.g. with ``request.getfixturevalue``. Previously these parameters were simply 7576 never defined, so a fixture decorated like ``@pytest.fixture(params=[0, 1, 2])`` 7577 only ran once (:pull:`460`). 7578 Thanks to :user:`nikratio` for the bug report, :user:`RedBeardCode` and :user:`tomviner` for the PR. 7579 7580 * ``_pytest.monkeypatch.monkeypatch`` class has been renamed to ``_pytest.monkeypatch.MonkeyPatch`` 7581 so it doesn't conflict with the ``monkeypatch`` fixture. 7582 7583 * ``--exitfirst / -x`` can now be overridden by a following ``--maxfail=N`` 7584 and is just a synonym for ``--maxfail=1``. 7585 7586 7587 **New Features** 7588 7589 * Support nose-style ``__test__`` attribute on methods of classes, 7590 including unittest-style Classes. If set to ``False``, the test will not be 7591 collected. 7592 7593 * New ``doctest_namespace`` fixture for injecting names into the 7594 namespace in which doctests run. 7595 Thanks :user:`milliams` for the complete PR (:pull:`1428`). 7596 7597 * New ``--doctest-report`` option available to change the output format of diffs 7598 when running (failing) doctests (implements :issue:`1749`). 7599 Thanks :user:`hartym` for the PR. 7600 7601 * New ``name`` argument to ``pytest.fixture`` decorator which allows a custom name 7602 for a fixture (to solve the funcarg-shadowing-fixture problem). 7603 Thanks :user:`novas0x2a` for the complete PR (:pull:`1444`). 7604 7605 * New ``approx()`` function for easily comparing floating-point numbers in 7606 tests. 7607 Thanks :user:`kalekundert` for the complete PR (:pull:`1441`). 7608 7609 * Ability to add global properties in the final xunit output file by accessing 7610 the internal ``junitxml`` plugin (experimental). 7611 Thanks :user:`tareqalayan` for the complete PR :pull:`1454`). 7612 7613 * New ``ExceptionInfo.match()`` method to match a regular expression on the 7614 string representation of an exception (:issue:`372`). 7615 Thanks :user:`omarkohl` for the complete PR (:pull:`1502`). 7616 7617 * ``__tracebackhide__`` can now also be set to a callable which then can decide 7618 whether to filter the traceback based on the ``ExceptionInfo`` object passed 7619 to it. Thanks :user:`The-Compiler` for the complete PR (:pull:`1526`). 7620 7621 * New ``pytest_make_parametrize_id(config, val)`` hook which can be used by plugins to provide 7622 friendly strings for custom types. 7623 Thanks :user:`palaviv` for the PR. 7624 7625 * ``capsys`` and ``capfd`` now have a ``disabled()`` context-manager method, which 7626 can be used to temporarily disable capture within a test. 7627 Thanks :user:`nicoddemus` for the PR. 7628 7629 * New cli flag ``--fixtures-per-test``: shows which fixtures are being used 7630 for each selected test item. Features doc strings of fixtures by default. 7631 Can also show where fixtures are defined if combined with ``-v``. 7632 Thanks :user:`hackebrot` for the PR. 7633 7634 * Introduce ``pytest`` command as recommended entry point. Note that ``py.test`` 7635 still works and is not scheduled for removal. Closes proposal 7636 :issue:`1629`. Thanks :user:`obestwalter` and :user:`davehunt` for the complete PR 7637 (:pull:`1633`). 7638 7639 * New cli flags: 7640 7641 + ``--setup-plan``: performs normal collection and reports 7642 the potential setup and teardown and does not execute any fixtures and tests; 7643 + ``--setup-only``: performs normal collection, executes setup and teardown of 7644 fixtures and reports them; 7645 + ``--setup-show``: performs normal test execution and additionally shows 7646 setup and teardown of fixtures; 7647 + ``--keep-duplicates``: py.test now ignores duplicated paths given in the command 7648 line. To retain the previous behavior where the same test could be run multiple 7649 times by specifying it in the command-line multiple times, pass the ``--keep-duplicates`` 7650 argument (:issue:`1609`); 7651 7652 Thanks :user:`d6e`, :user:`kvas-it`, :user:`sallner`, :user:`ioggstream` and :user:`omarkohl` for the PRs. 7653 7654 * New CLI flag ``--override-ini``/``-o``: overrides values from the ini file. 7655 For example: ``"-o xfail_strict=True"``'. 7656 Thanks :user:`blueyed` and :user:`fengxx` for the PR. 7657 7658 * New hooks: 7659 7660 + ``pytest_fixture_setup(fixturedef, request)``: executes fixture setup; 7661 + ``pytest_fixture_post_finalizer(fixturedef)``: called after the fixture's 7662 finalizer and has access to the fixture's result cache. 7663 7664 Thanks :user:`d6e`, :user:`sallner`. 7665 7666 * Issue warnings for asserts whose test is a tuple literal. Such asserts will 7667 never fail because tuples are always truthy and are usually a mistake 7668 (see :issue:`1562`). Thanks :user:`kvas-it`, for the PR. 7669 7670 * Allow passing a custom debugger class (e.g. ``--pdbcls=IPython.core.debugger:Pdb``). 7671 Thanks to :user:`anntzer` for the PR. 7672 7673 7674 **Changes** 7675 7676 * Plugins now benefit from assertion rewriting. Thanks 7677 :user:`sober7`, :user:`nicoddemus` and :user:`flub` for the PR. 7678 7679 * Change ``report.outcome`` for ``xpassed`` tests to ``"passed"`` in non-strict 7680 mode and ``"failed"`` in strict mode. Thanks to :user:`hackebrot` for the PR 7681 (:pull:`1795`) and :user:`gprasad84` for report (:issue:`1546`). 7682 7683 * Tests marked with ``xfail(strict=False)`` (the default) now appear in 7684 JUnitXML reports as passing tests instead of skipped. 7685 Thanks to :user:`hackebrot` for the PR (:pull:`1795`). 7686 7687 * Highlight path of the file location in the error report to make it easier to copy/paste. 7688 Thanks :user:`suzaku` for the PR (:pull:`1778`). 7689 7690 * Fixtures marked with ``@pytest.fixture`` can now use ``yield`` statements exactly like 7691 those marked with the ``@pytest.yield_fixture`` decorator. This change renders 7692 ``@pytest.yield_fixture`` deprecated and makes ``@pytest.fixture`` with ``yield`` statements 7693 the preferred way to write teardown code (:pull:`1461`). 7694 Thanks :user:`csaftoiu` for bringing this to attention and :user:`nicoddemus` for the PR. 7695 7696 * Explicitly passed parametrize ids do not get escaped to ascii (:issue:`1351`). 7697 Thanks :user:`ceridwen` for the PR. 7698 7699 * Fixtures are now sorted in the error message displayed when an unknown 7700 fixture is declared in a test function. 7701 Thanks :user:`nicoddemus` for the PR. 7702 7703 * ``pytest_terminal_summary`` hook now receives the ``exitstatus`` 7704 of the test session as argument. Thanks :user:`blueyed` for the PR (:pull:`1809`). 7705 7706 * Parametrize ids can accept ``None`` as specific test id, in which case the 7707 automatically generated id for that argument will be used. 7708 Thanks :user:`palaviv` for the complete PR (:pull:`1468`). 7709 7710 * The parameter to xunit-style setup/teardown methods (``setup_method``, 7711 ``setup_module``, etc.) is now optional and may be omitted. 7712 Thanks :user:`okken` for bringing this to attention and :user:`nicoddemus` for the PR. 7713 7714 * Improved automatic id generation selection in case of duplicate ids in 7715 parametrize. 7716 Thanks :user:`palaviv` for the complete PR (:pull:`1474`). 7717 7718 * Now pytest warnings summary is shown up by default. Added a new flag 7719 ``--disable-pytest-warnings`` to explicitly disable the warnings summary (:issue:`1668`). 7720 7721 * Make ImportError during collection more explicit by reminding 7722 the user to check the name of the test module/package(s) (:issue:`1426`). 7723 Thanks :user:`omarkohl` for the complete PR (:pull:`1520`). 7724 7725 * Add ``build/`` and ``dist/`` to the default ``--norecursedirs`` list. Thanks 7726 :user:`mikofski` for the report and :user:`tomviner` for the PR (:issue:`1544`). 7727 7728 * ``pytest.raises`` in the context manager form accepts a custom 7729 ``message`` to raise when no exception occurred. 7730 Thanks :user:`palaviv` for the complete PR (:pull:`1616`). 7731 7732 * ``conftest.py`` files now benefit from assertion rewriting; previously it 7733 was only available for test modules. Thanks :user:`flub`, :user:`sober7` and 7734 :user:`nicoddemus` for the PR (:issue:`1619`). 7735 7736 * Text documents without any doctests no longer appear as "skipped". 7737 Thanks :user:`graingert` for reporting and providing a full PR (:pull:`1580`). 7738 7739 * Ensure that a module within a namespace package can be found when it 7740 is specified on the command line together with the ``--pyargs`` 7741 option. Thanks to :user:`taschini` for the PR (:pull:`1597`). 7742 7743 * Always include full assertion explanation during assertion rewriting. The previous behaviour was hiding 7744 sub-expressions that happened to be ``False``, assuming this was redundant information. 7745 Thanks :user:`bagerard` for reporting (:issue:`1503`). Thanks to :user:`davehunt` and 7746 :user:`tomviner` for the PR. 7747 7748 * ``OptionGroup.addoption()`` now checks if option names were already 7749 added before, to make it easier to track down issues like :issue:`1618`. 7750 Before, you only got exceptions later from ``argparse`` library, 7751 giving no clue about the actual reason for double-added options. 7752 7753 * ``yield``-based tests are considered deprecated and will be removed in pytest-4.0. 7754 Thanks :user:`nicoddemus` for the PR. 7755 7756 * ``[pytest]`` sections in ``setup.cfg`` files should now be named ``[tool:pytest]`` 7757 to avoid conflicts with other distutils commands (see :pull:`567`). ``[pytest]`` sections in 7758 ``pytest.ini`` or ``tox.ini`` files are supported and unchanged. 7759 Thanks :user:`nicoddemus` for the PR. 7760 7761 * Using ``pytest_funcarg__`` prefix to declare fixtures is considered deprecated and will be 7762 removed in pytest-4.0 (:pull:`1684`). 7763 Thanks :user:`nicoddemus` for the PR. 7764 7765 * Passing a command-line string to ``pytest.main()`` is considered deprecated and scheduled 7766 for removal in pytest-4.0. It is recommended to pass a list of arguments instead (:pull:`1723`). 7767 7768 * Rename ``getfuncargvalue`` to ``getfixturevalue``. ``getfuncargvalue`` is 7769 still present but is now considered deprecated. Thanks to :user:`RedBeardCode` and :user:`tomviner` 7770 for the PR (:pull:`1626`). 7771 7772 * ``optparse`` type usage now triggers DeprecationWarnings (:issue:`1740`). 7773 7774 7775 * ``optparse`` backward compatibility supports float/complex types (:issue:`457`). 7776 7777 * Refined logic for determining the ``rootdir``, considering only valid 7778 paths which fixes a number of issues: :issue:`1594`, :issue:`1435` and :issue:`1471`. 7779 Updated the documentation according to current behavior. Thanks to 7780 :user:`blueyed`, :user:`davehunt` and :user:`matthiasha` for the PR. 7781 7782 * Always include full assertion explanation. The previous behaviour was hiding 7783 sub-expressions that happened to be False, assuming this was redundant information. 7784 Thanks :user:`bagerard` for reporting (:issue:`1503`). Thanks to :user:`davehunt` and 7785 :user:`tomviner` for PR. 7786 7787 * Better message in case of not using parametrized variable (see :issue:`1539`). 7788 Thanks to :user:`tramwaj29` for the PR. 7789 7790 * Updated docstrings with a more uniform style. 7791 7792 * Add stderr write for ``pytest.exit(msg)`` during startup. Previously the message was never shown. 7793 Thanks :user:`BeyondEvil` for reporting :issue:`1210`. Thanks to @jgsonesen and 7794 :user:`tomviner` for the PR. 7795 7796 * No longer display the incorrect test deselection reason (:issue:`1372`). 7797 Thanks :user:`ronnypfannschmidt` for the PR. 7798 7799 * The ``--resultlog`` command line option has been deprecated: it is little used 7800 and there are more modern and better alternatives (see :issue:`830`). 7801 Thanks :user:`nicoddemus` for the PR. 7802 7803 * Improve error message with fixture lookup errors: add an 'E' to the first 7804 line and '>' to the rest. Fixes :issue:`717`. Thanks :user:`blueyed` for reporting and 7805 a PR, :user:`eolo999` for the initial PR and :user:`tomviner` for his guidance during 7806 EuroPython2016 sprint. 7807 7808 7809 **Bug Fixes** 7810 7811 * Parametrize now correctly handles duplicated test ids. 7812 7813 * Fix internal error issue when the ``method`` argument is missing for 7814 ``teardown_method()`` (:issue:`1605`). 7815 7816 * Fix exception visualization in case the current working directory (CWD) gets 7817 deleted during testing (:issue:`1235`). Thanks :user:`bukzor` for reporting. PR by 7818 :user:`marscher`. 7819 7820 * Improve test output for logical expression with brackets (:issue:`925`). 7821 Thanks :user:`DRMacIver` for reporting and :user:`RedBeardCode` for the PR. 7822 7823 * Create correct diff for strings ending with newlines (:issue:`1553`). 7824 Thanks :user:`Vogtinator` for reporting and :user:`RedBeardCode` and 7825 :user:`tomviner` for the PR. 7826 7827 * ``ConftestImportFailure`` now shows the traceback making it easier to 7828 identify bugs in ``conftest.py`` files (:pull:`1516`). Thanks :user:`txomon` for 7829 the PR. 7830 7831 * Text documents without any doctests no longer appear as "skipped". 7832 Thanks :user:`graingert` for reporting and providing a full PR (:pull:`1580`). 7833 7834 * Fixed collection of classes with custom ``__new__`` method. 7835 Fixes :issue:`1579`. Thanks to :user:`Stranger6667` for the PR. 7836 7837 * Fixed scope overriding inside metafunc.parametrize (:issue:`634`). 7838 Thanks to :user:`Stranger6667` for the PR. 7839 7840 * Fixed the total tests tally in junit xml output (:pull:`1798`). 7841 Thanks to :user:`cboelsen` for the PR. 7842 7843 * Fixed off-by-one error with lines from ``request.node.warn``. 7844 Thanks to :user:`blueyed` for the PR. 7845 7846 7847 2.9.2 (2016-05-31) 7848 ================== 7849 7850 **Bug Fixes** 7851 7852 * fix :issue:`510`: skip tests where one parameterize dimension was empty 7853 thanks Alex Stapleton for the Report and :user:`RonnyPfannschmidt` for the PR 7854 7855 * Fix Xfail does not work with condition keyword argument. 7856 Thanks :user:`astraw38` for reporting the issue (:issue:`1496`) and :user:`tomviner` 7857 for PR the (:pull:`1524`). 7858 7859 * Fix win32 path issue when putting custom config file with absolute path 7860 in ``pytest.main("-c your_absolute_path")``. 7861 7862 * Fix maximum recursion depth detection when raised error class is not aware 7863 of unicode/encoded bytes. 7864 Thanks :user:`prusse-martin` for the PR (:pull:`1506`). 7865 7866 * Fix ``pytest.mark.skip`` mark when used in strict mode. 7867 Thanks :user:`pquentin` for the PR and :user:`RonnyPfannschmidt` for 7868 showing how to fix the bug. 7869 7870 * Minor improvements and fixes to the documentation. 7871 Thanks :user:`omarkohl` for the PR. 7872 7873 * Fix ``--fixtures`` to show all fixture definitions as opposed to just 7874 one per fixture name. 7875 Thanks to :user:`hackebrot` for the PR. 7876 7877 7878 2.9.1 (2016-03-17) 7879 ================== 7880 7881 **Bug Fixes** 7882 7883 * Improve error message when a plugin fails to load. 7884 Thanks :user:`nicoddemus` for the PR. 7885 7886 * Fix (:issue:`1178`): 7887 ``pytest.fail`` with non-ascii characters raises an internal pytest error. 7888 Thanks :user:`nicoddemus` for the PR. 7889 7890 * Fix (:issue:`469`): junit parses report.nodeid incorrectly, when params IDs 7891 contain ``::``. Thanks :user:`tomviner` for the PR (:pull:`1431`). 7892 7893 * Fix (:issue:`578`): SyntaxErrors 7894 containing non-ascii lines at the point of failure generated an internal 7895 py.test error. 7896 Thanks :user:`asottile` for the report and :user:`nicoddemus` for the PR. 7897 7898 * Fix (:issue:`1437`): When passing in a bytestring regex pattern to parameterize 7899 attempt to decode it as utf-8 ignoring errors. 7900 7901 * Fix (:issue:`649`): parametrized test nodes cannot be specified to run on the command line. 7902 7903 * Fix (:issue:`138`): better reporting for python 3.3+ chained exceptions 7904 7905 7906 2.9.0 (2016-02-29) 7907 ================== 7908 7909 **New Features** 7910 7911 * New ``pytest.mark.skip`` mark, which unconditionally skips marked tests. 7912 Thanks :user:`MichaelAquilina` for the complete PR (:pull:`1040`). 7913 7914 * ``--doctest-glob`` may now be passed multiple times in the command-line. 7915 Thanks :user:`jab` and :user:`nicoddemus` for the PR. 7916 7917 * New ``-rp`` and ``-rP`` reporting options give the summary and full output 7918 of passing tests, respectively. Thanks to :user:`codewarrior0` for the PR. 7919 7920 * ``pytest.mark.xfail`` now has a ``strict`` option, which makes ``XPASS`` 7921 tests to fail the test suite (defaulting to ``False``). There's also a 7922 ``xfail_strict`` ini option that can be used to configure it project-wise. 7923 Thanks :user:`rabbbit` for the request and :user:`nicoddemus` for the PR (:pull:`1355`). 7924 7925 * ``Parser.addini`` now supports options of type ``bool``. 7926 Thanks :user:`nicoddemus` for the PR. 7927 7928 * New ``ALLOW_BYTES`` doctest option. This strips ``b`` prefixes from byte strings 7929 in doctest output (similar to ``ALLOW_UNICODE``). 7930 Thanks :user:`jaraco` for the request and :user:`nicoddemus` for the PR (:pull:`1287`). 7931 7932 * Give a hint on ``KeyboardInterrupt`` to use the ``--fulltrace`` option to show the errors. 7933 Fixes :issue:`1366`. 7934 Thanks to :user:`hpk42` for the report and :user:`RonnyPfannschmidt` for the PR. 7935 7936 * Catch ``IndexError`` exceptions when getting exception source location. 7937 Fixes a pytest internal error for dynamically generated code (fixtures and tests) 7938 where source lines are fake by intention. 7939 7940 **Changes** 7941 7942 * **Important**: `py.code <https://pylib.readthedocs.io/en/stable/code.html>`_ has been 7943 merged into the ``pytest`` repository as ``pytest._code``. This decision 7944 was made because ``py.code`` had very few uses outside ``pytest`` and the 7945 fact that it was in a different repository made it difficult to fix bugs on 7946 its code in a timely manner. The team hopes with this to be able to better 7947 refactor out and improve that code. 7948 This change shouldn't affect users, but it is useful to let users aware 7949 if they encounter any strange behavior. 7950 7951 Keep in mind that the code for ``pytest._code`` is **private** and 7952 **experimental**, so you definitely should not import it explicitly! 7953 7954 Please note that the original ``py.code`` is still available in 7955 `pylib <https://pylib.readthedocs.io>`_. 7956 7957 * ``pytest_enter_pdb`` now optionally receives the pytest config object. 7958 Thanks :user:`nicoddemus` for the PR. 7959 7960 * Removed code and documentation for Python 2.5 or lower versions, 7961 including removal of the obsolete ``_pytest.assertion.oldinterpret`` module. 7962 Thanks :user:`nicoddemus` for the PR (:pull:`1226`). 7963 7964 * Comparisons now always show up in full when ``CI`` or ``BUILD_NUMBER`` is 7965 found in the environment, even when ``-vv`` isn't used. 7966 Thanks :user:`The-Compiler` for the PR. 7967 7968 * ``--lf`` and ``--ff`` now support long names: ``--last-failed`` and 7969 ``--failed-first`` respectively. 7970 Thanks :user:`MichaelAquilina` for the PR. 7971 7972 * Added expected exceptions to ``pytest.raises`` fail message. 7973 7974 * Collection only displays progress ("collecting X items") when in a terminal. 7975 This avoids cluttering the output when using ``--color=yes`` to obtain 7976 colors in CI integrations systems (:issue:`1397`). 7977 7978 **Bug Fixes** 7979 7980 * The ``-s`` and ``-c`` options should now work under ``xdist``; 7981 ``Config.fromdictargs`` now represents its input much more faithfully. 7982 Thanks to :user:`bukzor` for the complete PR (:issue:`680`). 7983 7984 * Fix (:issue:`1290`): support Python 3.5's ``@`` operator in assertion rewriting. 7985 Thanks :user:`Shinkenjoe` for report with test case and :user:`tomviner` for the PR. 7986 7987 * Fix formatting utf-8 explanation messages (:issue:`1379`). 7988 Thanks :user:`biern` for the PR. 7989 7990 * Fix :ref:`traceback style docs <how-to-modifying-python-tb-printing>` to describe all of the available options 7991 (auto/long/short/line/native/no), with ``auto`` being the default since v2.6. 7992 Thanks :user:`hackebrot` for the PR. 7993 7994 * Fix (:issue:`1422`): junit record_xml_property doesn't allow multiple records 7995 with same name. 7996 7997 7998 2.8.7 (2016-01-24) 7999 ================== 8000 8001 - fix #1338: use predictable object resolution for monkeypatch 8002 8003 2.8.6 (2016-01-21) 8004 ================== 8005 8006 - fix #1259: allow for double nodeids in junitxml, 8007 this was a regression failing plugins combinations 8008 like pytest-pep8 + pytest-flakes 8009 8010 - Workaround for exception that occurs in pyreadline when using 8011 ``--pdb`` with standard I/O capture enabled. 8012 Thanks Erik M. Bray for the PR. 8013 8014 - fix #900: Better error message in case the target of a ``monkeypatch`` call 8015 raises an ``ImportError``. 8016 8017 - fix #1292: monkeypatch calls (setattr, setenv, etc.) are now O(1). 8018 Thanks David R. MacIver for the report and Bruno Oliveira for the PR. 8019 8020 - fix #1223: captured stdout and stderr are now properly displayed before 8021 entering pdb when ``--pdb`` is used instead of being thrown away. 8022 Thanks Cal Leeming for the PR. 8023 8024 - fix #1305: pytest warnings emitted during ``pytest_terminal_summary`` are now 8025 properly displayed. 8026 Thanks Ionel Maries Cristian for the report and Bruno Oliveira for the PR. 8027 8028 - fix #628: fixed internal UnicodeDecodeError when doctests contain unicode. 8029 Thanks Jason R. Coombs for the report and Bruno Oliveira for the PR. 8030 8031 - fix #1334: Add captured stdout to jUnit XML report on setup error. 8032 Thanks Georgy Dyuldin for the PR. 8033 8034 8035 2.8.5 (2015-12-11) 8036 ================== 8037 8038 - fix #1243: fixed issue where class attributes injected during collection could break pytest. 8039 PR by Alexei Kozlenok, thanks Ronny Pfannschmidt and Bruno Oliveira for the review and help. 8040 8041 - fix #1074: precompute junitxml chunks instead of storing the whole tree in objects 8042 Thanks Bruno Oliveira for the report and Ronny Pfannschmidt for the PR 8043 8044 - fix #1238: fix ``pytest.deprecated_call()`` receiving multiple arguments 8045 (Regression introduced in 2.8.4). Thanks Alex Gaynor for the report and 8046 Bruno Oliveira for the PR. 8047 8048 8049 2.8.4 (2015-12-06) 8050 ================== 8051 8052 - fix #1190: ``deprecated_call()`` now works when the deprecated 8053 function has been already called by another test in the same 8054 module. Thanks Mikhail Chernykh for the report and Bruno Oliveira for the 8055 PR. 8056 8057 - fix #1198: ``--pastebin`` option now works on Python 3. Thanks 8058 Mehdy Khoshnoody for the PR. 8059 8060 - fix #1219: ``--pastebin`` now works correctly when captured output contains 8061 non-ascii characters. Thanks Bruno Oliveira for the PR. 8062 8063 - fix #1204: another error when collecting with a nasty __getattr__(). 8064 Thanks Florian Bruhin for the PR. 8065 8066 - fix the summary printed when no tests did run. 8067 Thanks Florian Bruhin for the PR. 8068 - fix #1185 - ensure MANIFEST.in exactly matches what should go to a sdist 8069 8070 - a number of documentation modernizations wrt good practices. 8071 Thanks Bruno Oliveira for the PR. 8072 8073 2.8.3 (2015-11-18) 8074 ================== 8075 8076 - fix #1169: add __name__ attribute to testcases in TestCaseFunction to 8077 support the @unittest.skip decorator on functions and methods. 8078 Thanks Lee Kamentsky for the PR. 8079 8080 - fix #1035: collecting tests if test module level obj has __getattr__(). 8081 Thanks Suor for the report and Bruno Oliveira / Tom Viner for the PR. 8082 8083 - fix #331: don't collect tests if their failure cannot be reported correctly 8084 e.g. they are a callable instance of a class. 8085 8086 - fix #1133: fixed internal error when filtering tracebacks where one entry 8087 belongs to a file which is no longer available. 8088 Thanks Bruno Oliveira for the PR. 8089 8090 - enhancement made to highlight in red the name of the failing tests so 8091 they stand out in the output. 8092 Thanks Gabriel Reis for the PR. 8093 8094 - add more talks to the documentation 8095 - extend documentation on the --ignore cli option 8096 - use pytest-runner for setuptools integration 8097 - minor fixes for interaction with OS X El Capitan 8098 system integrity protection (thanks Florian) 8099 8100 8101 2.8.2 (2015-10-07) 8102 ================== 8103 8104 - fix #1085: proper handling of encoding errors when passing encoded byte 8105 strings to pytest.parametrize in Python 2. 8106 Thanks Themanwithoutaplan for the report and Bruno Oliveira for the PR. 8107 8108 - fix #1087: handling SystemError when passing empty byte strings to 8109 pytest.parametrize in Python 3. 8110 Thanks Paul Kehrer for the report and Bruno Oliveira for the PR. 8111 8112 - fix #995: fixed internal error when filtering tracebacks where one entry 8113 was generated by an exec() statement. 8114 Thanks Daniel Hahler, Ashley C Straw, Philippe Gauthier and Pavel Savchenko 8115 for contributing and Bruno Oliveira for the PR. 8116 8117 - fix #1100 and #1057: errors when using autouse fixtures and doctest modules. 8118 Thanks Sergey B Kirpichev and Vital Kudzelka for contributing and Bruno 8119 Oliveira for the PR. 8120 8121 2.8.1 (2015-09-29) 8122 ================== 8123 8124 - fix #1034: Add missing nodeid on pytest_logwarning call in 8125 addhook. Thanks Simon Gomizelj for the PR. 8126 8127 - 'deprecated_call' is now only satisfied with a DeprecationWarning or 8128 PendingDeprecationWarning. Before 2.8.0, it accepted any warning, and 2.8.0 8129 made it accept only DeprecationWarning (but not PendingDeprecationWarning). 8130 Thanks Alex Gaynor for the issue and Eric Hunsberger for the PR. 8131 8132 - fix issue #1073: avoid calling __getattr__ on potential plugin objects. 8133 This fixes an incompatibility with pytest-django. Thanks Andreas Pelme, 8134 Bruno Oliveira and Ronny Pfannschmidt for contributing and Holger Krekel 8135 for the fix. 8136 8137 - Fix issue #704: handle versionconflict during plugin loading more 8138 gracefully. Thanks Bruno Oliveira for the PR. 8139 8140 - Fix issue #1064: ""--junitxml" regression when used with the 8141 "pytest-xdist" plugin, with test reports being assigned to the wrong tests. 8142 Thanks Daniel Grunwald for the report and Bruno Oliveira for the PR. 8143 8144 - (experimental) adapt more SEMVER style versioning and change meaning of 8145 master branch in git repo: "master" branch now keeps the bug fixes, changes 8146 aimed for micro releases. "features" branch will only be released 8147 with minor or major pytest releases. 8148 8149 - Fix issue #766 by removing documentation references to distutils. 8150 Thanks Russel Winder. 8151 8152 - Fix issue #1030: now byte-strings are escaped to produce item node ids 8153 to make them always serializable. 8154 Thanks Andy Freeland for the report and Bruno Oliveira for the PR. 8155 8156 - Python 2: if unicode parametrized values are convertible to ascii, their 8157 ascii representation is used for the node id. 8158 8159 - Fix issue #411: Add __eq__ method to assertion comparison example. 8160 Thanks Ben Webb. 8161 - Fix issue #653: deprecated_call can be used as context manager. 8162 8163 - fix issue 877: properly handle assertion explanations with non-ascii repr 8164 Thanks Mathieu Agopian for the report and Ronny Pfannschmidt for the PR. 8165 8166 - fix issue 1029: transform errors when writing cache values into pytest-warnings 8167 8168 2.8.0 (2015-09-18) 8169 ================== 8170 8171 - new ``--lf`` and ``-ff`` options to run only the last failing tests or 8172 "failing tests first" from the last run. This functionality is provided 8173 through porting the formerly external pytest-cache plugin into pytest core. 8174 BACKWARD INCOMPAT: if you used pytest-cache's functionality to persist 8175 data between test runs be aware that we don't serialize sets anymore. 8176 Thanks Ronny Pfannschmidt for most of the merging work. 8177 8178 - "-r" option now accepts "a" to include all possible reports, similar 8179 to passing "fEsxXw" explicitly (issue960). 8180 Thanks Abhijeet Kasurde for the PR. 8181 8182 - avoid python3.5 deprecation warnings by introducing version 8183 specific inspection helpers, thanks Michael Droettboom. 8184 8185 - fix issue562: @nose.tools.istest now fully respected. 8186 8187 - fix issue934: when string comparison fails and a diff is too large to display 8188 without passing -vv, still show a few lines of the diff. 8189 Thanks Florian Bruhin for the report and Bruno Oliveira for the PR. 8190 8191 - fix issue736: Fix a bug where fixture params would be discarded when combined 8192 with parametrization markers. 8193 Thanks to Markus Unterwaditzer for the PR. 8194 8195 - fix issue710: introduce ALLOW_UNICODE doctest option: when enabled, the 8196 ``u`` prefix is stripped from unicode strings in expected doctest output. This 8197 allows doctests which use unicode to run in Python 2 and 3 unchanged. 8198 Thanks Jason R. Coombs for the report and Bruno Oliveira for the PR. 8199 8200 - parametrize now also generates meaningful test IDs for enum, regex and class 8201 objects (as opposed to class instances). 8202 Thanks to Florian Bruhin for the PR. 8203 8204 - Add 'warns' to assert that warnings are thrown (like 'raises'). 8205 Thanks to Eric Hunsberger for the PR. 8206 8207 - Fix issue683: Do not apply an already applied mark. Thanks ojake for the PR. 8208 8209 - Deal with capturing failures better so fewer exceptions get lost to 8210 /dev/null. Thanks David Szotten for the PR. 8211 8212 - fix issue730: deprecate and warn about the --genscript option. 8213 Thanks Ronny Pfannschmidt for the report and Christian Pommranz for the PR. 8214 8215 - fix issue751: multiple parametrize with ids bug if it parametrizes class with 8216 two or more test methods. Thanks Sergey Chipiga for reporting and Jan 8217 Bednarik for PR. 8218 8219 - fix issue82: avoid loading conftest files from setup.cfg/pytest.ini/tox.ini 8220 files and upwards by default (--confcutdir can still be set to override this). 8221 Thanks Bruno Oliveira for the PR. 8222 8223 - fix issue768: docstrings found in python modules were not setting up session 8224 fixtures. Thanks Jason R. Coombs for reporting and Bruno Oliveira for the PR. 8225 8226 - added ``tmpdir_factory``, a session-scoped fixture that can be used to create 8227 directories under the base temporary directory. Previously this object was 8228 installed as a ``_tmpdirhandler`` attribute of the ``config`` object, but now it 8229 is part of the official API and using ``config._tmpdirhandler`` is 8230 deprecated. 8231 Thanks Bruno Oliveira for the PR. 8232 8233 - fix issue808: pytest's internal assertion rewrite hook now implements the 8234 optional :pep:`302` get_data API so tests can access data files next to them. 8235 Thanks xmo-odoo for request and example and Bruno Oliveira for 8236 the PR. 8237 8238 - rootdir and inifile are now displayed during usage errors to help 8239 users diagnose problems such as unexpected ini files which add 8240 unknown options being picked up by pytest. Thanks to Pavel Savchenko for 8241 bringing the problem to attention in #821 and Bruno Oliveira for the PR. 8242 8243 - Summary bar now is colored yellow for warning 8244 situations such as: all tests either were skipped or xpass/xfailed, 8245 or no tests were run at all (this is a partial fix for issue500). 8246 8247 - fix issue812: pytest now exits with status code 5 in situations where no 8248 tests were run at all, such as the directory given in the command line does 8249 not contain any tests or as result of a command line option filters 8250 all out all tests (-k for example). 8251 Thanks Eric Siegerman (issue812) and Bruno Oliveira for the PR. 8252 8253 - Summary bar now is colored yellow for warning 8254 situations such as: all tests either were skipped or xpass/xfailed, 8255 or no tests were run at all (related to issue500). 8256 Thanks Eric Siegerman. 8257 8258 - New ``testpaths`` ini option: list of directories to search for tests 8259 when executing pytest from the root directory. This can be used 8260 to speed up test collection when a project has well specified directories 8261 for tests, being usually more practical than configuring norecursedirs for 8262 all directories that do not contain tests. 8263 Thanks to Adrian for idea (#694) and Bruno Oliveira for the PR. 8264 8265 - fix issue713: JUnit XML reports for doctest failures. 8266 Thanks Punyashloka Biswal. 8267 8268 - fix issue970: internal pytest warnings now appear as "pytest-warnings" in 8269 the terminal instead of "warnings", so it is clear for users that those 8270 warnings are from pytest and not from the builtin "warnings" module. 8271 Thanks Bruno Oliveira. 8272 8273 - Include setup and teardown in junitxml test durations. 8274 Thanks Janne Vanhala. 8275 8276 - fix issue735: assertion failures on debug versions of Python 3.4+ 8277 8278 - new option ``--import-mode`` to allow to change test module importing 8279 behaviour to append to sys.path instead of prepending. This better allows 8280 to run test modules against installed versions of a package even if the 8281 package under test has the same import root. In this example:: 8282 8283 testing/__init__.py 8284 testing/test_pkg_under_test.py 8285 pkg_under_test/ 8286 8287 the tests will run against the installed version 8288 of pkg_under_test when ``--import-mode=append`` is used whereas 8289 by default they would always pick up the local version. Thanks Holger Krekel. 8290 8291 - pytester: add method ``TmpTestdir.delete_loaded_modules()``, and call it 8292 from ``inline_run()`` to allow temporary modules to be reloaded. 8293 Thanks Eduardo Schettino. 8294 8295 - internally refactor pluginmanager API and code so that there 8296 is a clear distinction between a pytest-agnostic rather simple 8297 pluginmanager and the PytestPluginManager which adds a lot of 8298 behaviour, among it handling of the local conftest files. 8299 In terms of documented methods this is a backward compatible 8300 change but it might still break 3rd party plugins which relied on 8301 details like especially the pluginmanager.add_shutdown() API. 8302 Thanks Holger Krekel. 8303 8304 - pluginmanagement: introduce ``pytest.hookimpl`` and 8305 ``pytest.hookspec`` decorators for setting impl/spec 8306 specific parameters. This substitutes the previous 8307 now deprecated use of ``pytest.mark`` which is meant to 8308 contain markers for test functions only. 8309 8310 - write/refine docs for "writing plugins" which now have their 8311 own page and are separate from the "using/installing plugins`` page. 8312 8313 - fix issue732: properly unregister plugins from any hook calling 8314 sites allowing to have temporary plugins during test execution. 8315 8316 - deprecate and warn about ``__multicall__`` argument in hook 8317 implementations. Use the ``hookwrapper`` mechanism instead already 8318 introduced with pytest-2.7. 8319 8320 - speed up pytest's own test suite considerably by using inprocess 8321 tests by default (testrun can be modified with --runpytest=subprocess 8322 to create subprocesses in many places instead). The main 8323 APIs to run pytest in a test is "runpytest()" or "runpytest_subprocess" 8324 and "runpytest_inprocess" if you need a particular way of running 8325 the test. In all cases you get back a RunResult but the inprocess 8326 one will also have a "reprec" attribute with the recorded events/reports. 8327 8328 - fix monkeypatch.setattr("x.y", raising=False) to actually not raise 8329 if "y" is not a preexisting attribute. Thanks Florian Bruhin. 8330 8331 - fix issue741: make running output from testdir.run copy/pasteable 8332 Thanks Bruno Oliveira. 8333 8334 - add a new ``--noconftest`` argument which ignores all ``conftest.py`` files. 8335 8336 - add ``file`` and ``line`` attributes to JUnit-XML output. 8337 8338 - fix issue890: changed extension of all documentation files from ``txt`` to 8339 ``rst``. Thanks to Abhijeet for the PR. 8340 8341 - fix issue714: add ability to apply indirect=True parameter on particular argnames. 8342 Thanks Elizaveta239. 8343 8344 - fix issue890: changed extension of all documentation files from ``txt`` to 8345 ``rst``. Thanks to Abhijeet for the PR. 8346 8347 - fix issue957: "# doctest: SKIP" option will now register doctests as SKIPPED 8348 rather than PASSED. 8349 Thanks Thomas Grainger for the report and Bruno Oliveira for the PR. 8350 8351 - issue951: add new record_xml_property fixture, that supports logging 8352 additional information on xml output. Thanks David Diaz for the PR. 8353 8354 - issue949: paths after normal options (for example ``-s``, ``-v``, etc) are now 8355 properly used to discover ``rootdir`` and ``ini`` files. 8356 Thanks Peter Lauri for the report and Bruno Oliveira for the PR. 8357 8358 2.7.3 (2015-09-15) 8359 ================== 8360 8361 - Allow 'dev', 'rc', or other non-integer version strings in ``importorskip``. 8362 Thanks to Eric Hunsberger for the PR. 8363 8364 - fix issue856: consider --color parameter in all outputs (for example 8365 --fixtures). Thanks Barney Gale for the report and Bruno Oliveira for the PR. 8366 8367 - fix issue855: passing str objects as ``plugins`` argument to pytest.main 8368 is now interpreted as a module name to be imported and registered as a 8369 plugin, instead of silently having no effect. 8370 Thanks xmo-odoo for the report and Bruno Oliveira for the PR. 8371 8372 - fix issue744: fix for ast.Call changes in Python 3.5+. Thanks 8373 Guido van Rossum, Matthias Bussonnier, Stefan Zimmermann and 8374 Thomas Kluyver. 8375 8376 - fix issue842: applying markers in classes no longer propagate this markers 8377 to superclasses which also have markers. 8378 Thanks xmo-odoo for the report and Bruno Oliveira for the PR. 8379 8380 - preserve warning functions after call to pytest.deprecated_call. Thanks 8381 Pieter Mulder for PR. 8382 8383 - fix issue854: autouse yield_fixtures defined as class members of 8384 unittest.TestCase subclasses now work as expected. 8385 Thanks xmo-odoo for the report and Bruno Oliveira for the PR. 8386 8387 - fix issue833: --fixtures now shows all fixtures of collected test files, instead of just the 8388 fixtures declared on the first one. 8389 Thanks Florian Bruhin for reporting and Bruno Oliveira for the PR. 8390 8391 - fix issue863: skipped tests now report the correct reason when a skip/xfail 8392 condition is met when using multiple markers. 8393 Thanks Raphael Pierzina for reporting and Bruno Oliveira for the PR. 8394 8395 - optimized tmpdir fixture initialization, which should make test sessions 8396 faster (specially when using pytest-xdist). The only visible effect 8397 is that now pytest uses a subdirectory in the $TEMP directory for all 8398 directories created by this fixture (defaults to $TEMP/pytest-$USER). 8399 Thanks Bruno Oliveira for the PR. 8400 8401 2.7.2 (2015-06-23) 8402 ================== 8403 8404 - fix issue767: pytest.raises value attribute does not contain the exception 8405 instance on Python 2.6. Thanks Eric Siegerman for providing the test 8406 case and Bruno Oliveira for PR. 8407 8408 - Automatically create directory for junitxml and results log. 8409 Thanks Aron Curzon. 8410 8411 - fix issue713: JUnit XML reports for doctest failures. 8412 Thanks Punyashloka Biswal. 8413 8414 - fix issue735: assertion failures on debug versions of Python 3.4+ 8415 Thanks Benjamin Peterson. 8416 8417 - fix issue114: skipif marker reports to internal skipping plugin; 8418 Thanks Floris Bruynooghe for reporting and Bruno Oliveira for the PR. 8419 8420 - fix issue748: unittest.SkipTest reports to internal pytest unittest plugin. 8421 Thanks Thomas De Schampheleire for reporting and Bruno Oliveira for the PR. 8422 8423 - fix issue718: failed to create representation of sets containing unsortable 8424 elements in python 2. Thanks Edison Gustavo Muenz. 8425 8426 - fix issue756, fix issue752 (and similar issues): depend on py-1.4.29 8427 which has a refined algorithm for traceback generation. 8428 8429 8430 2.7.1 (2015-05-19) 8431 ================== 8432 8433 - fix issue731: do not get confused by the braces which may be present 8434 and unbalanced in an object's repr while collapsing False 8435 explanations. Thanks Carl Meyer for the report and test case. 8436 8437 - fix issue553: properly handling inspect.getsourcelines failures in 8438 FixtureLookupError which would lead to an internal error, 8439 obfuscating the original problem. Thanks talljosh for initial 8440 diagnose/patch and Bruno Oliveira for final patch. 8441 8442 - fix issue660: properly report scope-mismatch-access errors 8443 independently from ordering of fixture arguments. Also 8444 avoid the pytest internal traceback which does not provide 8445 information to the user. Thanks Holger Krekel. 8446 8447 - streamlined and documented release process. Also all versions 8448 (in setup.py and documentation generation) are now read 8449 from _pytest/__init__.py. Thanks Holger Krekel. 8450 8451 - fixed docs to remove the notion that yield-fixtures are experimental. 8452 They are here to stay :) Thanks Bruno Oliveira. 8453 8454 - Support building wheels by using environment markers for the 8455 requirements. Thanks Ionel Maries Cristian. 8456 8457 - fixed regression to 2.6.4 which surfaced e.g. in lost stdout capture printing 8458 when tests raised SystemExit. Thanks Holger Krekel. 8459 8460 - reintroduced _pytest fixture of the pytester plugin which is used 8461 at least by pytest-xdist. 8462 8463 2.7.0 (2015-03-26) 8464 ================== 8465 8466 - fix issue435: make reload() work when assert rewriting is active. 8467 Thanks Daniel Hahler. 8468 8469 - fix issue616: conftest.py files and their contained fixtures are now 8470 properly considered for visibility, independently from the exact 8471 current working directory and test arguments that are used. 8472 Many thanks to Eric Siegerman and his PR235 which contains 8473 systematic tests for conftest visibility and now passes. 8474 This change also introduces the concept of a ``rootdir`` which 8475 is printed as a new pytest header and documented in the pytest 8476 customize web page. 8477 8478 - change reporting of "diverted" tests, i.e. tests that are collected 8479 in one file but actually come from another (e.g. when tests in a test class 8480 come from a base class in a different file). We now show the nodeid 8481 and indicate via a postfix the other file. 8482 8483 - add ability to set command line options by environment variable PYTEST_ADDOPTS. 8484 8485 - added documentation on the new pytest-dev teams on bitbucket and 8486 github. See https://pytest.org/en/stable/contributing.html . 8487 Thanks to Anatoly for pushing and initial work on this. 8488 8489 - fix issue650: new option ``--doctest-ignore-import-errors`` which 8490 will turn import errors in doctests into skips. Thanks Charles Cloud 8491 for the complete PR. 8492 8493 - fix issue655: work around different ways that cause python2/3 8494 to leak sys.exc_info into fixtures/tests causing failures in 3rd party code 8495 8496 - fix issue615: assertion rewriting did not correctly escape % signs 8497 when formatting boolean operations, which tripped over mixing 8498 booleans with modulo operators. Thanks to Tom Viner for the report, 8499 triaging and fix. 8500 8501 - implement issue351: add ability to specify parametrize ids as a callable 8502 to generate custom test ids. Thanks Brianna Laugher for the idea and 8503 implementation. 8504 8505 - introduce and document new hookwrapper mechanism useful for plugins 8506 which want to wrap the execution of certain hooks for their purposes. 8507 This supersedes the undocumented ``__multicall__`` protocol which 8508 pytest itself and some external plugins use. Note that pytest-2.8 8509 is scheduled to drop supporting the old ``__multicall__`` 8510 and only support the hookwrapper protocol. 8511 8512 - majorly speed up invocation of plugin hooks 8513 8514 - use hookwrapper mechanism in builtin pytest plugins. 8515 8516 - add a doctest ini option for doctest flags, thanks Holger Peters. 8517 8518 - add note to docs that if you want to mark a parameter and the 8519 parameter is a callable, you also need to pass in a reason to disambiguate 8520 it from the "decorator" case. Thanks Tom Viner. 8521 8522 - "python_classes" and "python_functions" options now support glob-patterns 8523 for test discovery, as discussed in issue600. Thanks Ldiary Translations. 8524 8525 - allow to override parametrized fixtures with non-parametrized ones and vice versa (bubenkoff). 8526 8527 - fix issue463: raise specific error for 'parameterize' misspelling (pfctdayelise). 8528 8529 - On failure, the ``sys.last_value``, ``sys.last_type`` and 8530 ``sys.last_traceback`` are set, so that a user can inspect the error 8531 via postmortem debugging (almarklein). 8532 8533 2.6.4 (2014-10-24) 8534 ================== 8535 8536 - Improve assertion failure reporting on iterables, by using ndiff and 8537 pprint. 8538 8539 - removed outdated japanese docs from source tree. 8540 8541 - docs for "pytest_addhooks" hook. Thanks Bruno Oliveira. 8542 8543 - updated plugin index docs. Thanks Bruno Oliveira. 8544 8545 - fix issue557: with "-k" we only allow the old style "-" for negation 8546 at the beginning of strings and even that is deprecated. Use "not" instead. 8547 This should allow to pick parametrized tests where "-" appeared in the parameter. 8548 8549 - fix issue604: Escape % character in the assertion message. 8550 8551 - fix issue620: add explanation in the --genscript target about what 8552 the binary blob means. Thanks Dinu Gherman. 8553 8554 - fix issue614: fixed pastebin support. 8555 8556 8557 - fix issue620: add explanation in the --genscript target about what 8558 the binary blob means. Thanks Dinu Gherman. 8559 8560 - fix issue614: fixed pastebin support. 8561 8562 2.6.3 (2014-09-24) 8563 ================== 8564 8565 - fix issue575: xunit-xml was reporting collection errors as failures 8566 instead of errors, thanks Oleg Sinyavskiy. 8567 8568 - fix issue582: fix setuptools example, thanks Laszlo Papp and Ronny 8569 Pfannschmidt. 8570 8571 - Fix infinite recursion bug when pickling capture.EncodedFile, thanks 8572 Uwe Schmitt. 8573 8574 - fix issue589: fix bad interaction with numpy and others when showing 8575 exceptions. Check for precise "maximum recursion depth exceed" exception 8576 instead of presuming any RuntimeError is that one (implemented in py 8577 dep). Thanks Charles Cloud for analysing the issue. 8578 8579 - fix conftest related fixture visibility issue: when running with a 8580 CWD outside of a test package pytest would get fixture discovery wrong. 8581 Thanks to Wolfgang Schnerring for figuring out a reproducible example. 8582 8583 - Introduce pytest_enter_pdb hook (needed e.g. by pytest_timeout to cancel the 8584 timeout when interactively entering pdb). Thanks Wolfgang Schnerring. 8585 8586 - check xfail/skip also with non-python function test items. Thanks 8587 Floris Bruynooghe. 8588 8589 2.6.2 (2014-09-05) 8590 ================== 8591 8592 - Added function pytest.freeze_includes(), which makes it easy to embed 8593 pytest into executables using tools like cx_freeze. 8594 See docs for examples and rationale. Thanks Bruno Oliveira. 8595 8596 - Improve assertion rewriting cache invalidation precision. 8597 8598 - fixed issue561: adapt autouse fixture example for python3. 8599 8600 - fixed issue453: assertion rewriting issue with __repr__ containing 8601 "\n{", "\n}" and "\n~". 8602 8603 - fix issue560: correctly display code if an "else:" or "finally:" is 8604 followed by statements on the same line. 8605 8606 - Fix example in monkeypatch documentation, thanks t-8ch. 8607 8608 - fix issue572: correct tmpdir doc example for python3. 8609 8610 - Do not mark as universal wheel because Python 2.6 is different from 8611 other builds due to the extra argparse dependency. Fixes issue566. 8612 Thanks sontek. 8613 8614 - Implement issue549: user-provided assertion messages now no longer 8615 replace the py.test introspection message but are shown in addition 8616 to them. 8617 8618 2.6.1 (2014-08-07) 8619 ================== 8620 8621 - No longer show line numbers in the --verbose output, the output is now 8622 purely the nodeid. The line number is still shown in failure reports. 8623 Thanks Floris Bruynooghe. 8624 8625 - fix issue437 where assertion rewriting could cause pytest-xdist worker nodes 8626 to collect different tests. Thanks Bruno Oliveira. 8627 8628 - fix issue555: add "errors" attribute to capture-streams to satisfy 8629 some distutils and possibly other code accessing sys.stdout.errors. 8630 8631 - fix issue547 capsys/capfd also work when output capturing ("-s") is disabled. 8632 8633 - address issue170: allow pytest.mark.xfail(...) to specify expected exceptions via 8634 an optional "raises=EXC" argument where EXC can be a single exception 8635 or a tuple of exception classes. Thanks David Mohr for the complete 8636 PR. 8637 8638 - fix integration of pytest with unittest.mock.patch decorator when 8639 it uses the "new" argument. Thanks Nicolas Delaby for test and PR. 8640 8641 - fix issue with detecting conftest files if the arguments contain 8642 "::" node id specifications (copy pasted from "-v" output) 8643 8644 - fix issue544 by only removing "@NUM" at the end of "::" separated parts 8645 and if the part has a ".py" extension 8646 8647 - don't use py.std import helper, rather import things directly. 8648 Thanks Bruno Oliveira. 8649 8650 2.6 8651 === 8652 8653 - Cache exceptions from fixtures according to their scope (issue 467). 8654 8655 - fix issue537: Avoid importing old assertion reinterpretation code by default. 8656 8657 - fix issue364: shorten and enhance tracebacks representation by default. 8658 The new "--tb=auto" option (default) will only display long tracebacks 8659 for the first and last entry. You can get the old behaviour of printing 8660 all entries as long entries with "--tb=long". Also short entries by 8661 default are now printed very similarly to "--tb=native" ones. 8662 8663 - fix issue514: teach assertion reinterpretation about private class attributes 8664 8665 - change -v output to include full node IDs of tests. Users can copy 8666 a node ID from a test run, including line number, and use it as a 8667 positional argument in order to run only a single test. 8668 8669 - fix issue 475: fail early and comprehensible if calling 8670 pytest.raises with wrong exception type. 8671 8672 - fix issue516: tell in getting-started about current dependencies. 8673 8674 - cleanup setup.py a bit and specify supported versions. Thanks Jurko 8675 Gospodnetic for the PR. 8676 8677 - change XPASS colour to yellow rather than red when tests are run 8678 with -v. 8679 8680 - fix issue473: work around mock putting an unbound method into a class 8681 dict when double-patching. 8682 8683 - fix issue498: if a fixture finalizer fails, make sure that 8684 the fixture is still invalidated. 8685 8686 - fix issue453: the result of the pytest_assertrepr_compare hook now gets 8687 it's newlines escaped so that format_exception does not blow up. 8688 8689 - internal new warning system: pytest will now produce warnings when 8690 it detects oddities in your test collection or execution. 8691 Warnings are ultimately sent to a new pytest_logwarning hook which is 8692 currently only implemented by the terminal plugin which displays 8693 warnings in the summary line and shows more details when -rw (report on 8694 warnings) is specified. 8695 8696 - change skips into warnings for test classes with an __init__ and 8697 callables in test modules which look like a test but are not functions. 8698 8699 - fix issue436: improved finding of initial conftest files from command 8700 line arguments by using the result of parse_known_args rather than 8701 the previous flaky heuristics. Thanks Marc Abramowitz for tests 8702 and initial fixing approaches in this area. 8703 8704 - fix issue #479: properly handle nose/unittest(2) SkipTest exceptions 8705 during collection/loading of test modules. Thanks to Marc Schlaich 8706 for the complete PR. 8707 8708 - fix issue490: include pytest_load_initial_conftests in documentation 8709 and improve docstring. 8710 8711 - fix issue472: clarify that ``pytest.config.getvalue()`` cannot work 8712 if it's triggered ahead of command line parsing. 8713 8714 - merge PR123: improved integration with mock.patch decorator on tests. 8715 8716 - fix issue412: messing with stdout/stderr FD-level streams is now 8717 captured without crashes. 8718 8719 - fix issue483: trial/py33 works now properly. Thanks Daniel Grana for PR. 8720 8721 - improve example for pytest integration with "python setup.py test" 8722 which now has a generic "-a" or "--pytest-args" option where you 8723 can pass additional options as a quoted string. Thanks Trevor Bekolay. 8724 8725 - simplified internal capturing mechanism and made it more robust 8726 against tests or setups changing FD1/FD2, also better integrated 8727 now with pytest.pdb() in single tests. 8728 8729 - improvements to pytest's own test-suite leakage detection, courtesy of PRs 8730 from Marc Abramowitz 8731 8732 - fix issue492: avoid leak in test_writeorg. Thanks Marc Abramowitz. 8733 8734 - fix issue493: don't run tests in doc directory with ``python setup.py test`` 8735 (use tox -e doctesting for that) 8736 8737 - fix issue486: better reporting and handling of early conftest loading failures 8738 8739 - some cleanup and simplification of internal conftest handling. 8740 8741 - work a bit harder to break reference cycles when catching exceptions. 8742 Thanks Jurko Gospodnetic. 8743 8744 - fix issue443: fix skip examples to use proper comparison. Thanks Alex 8745 Groenholm. 8746 8747 - support nose-style ``__test__`` attribute on modules, classes and 8748 functions, including unittest-style Classes. If set to False, the 8749 test will not be collected. 8750 8751 - fix issue512: show "<notset>" for arguments which might not be set 8752 in monkeypatch plugin. Improves output in documentation. 8753 8754 8755 2.5.2 (2014-01-29) 8756 ================== 8757 8758 - fix issue409 -- better interoperate with cx_freeze by not 8759 trying to import from collections.abc which causes problems 8760 for py27/cx_freeze. Thanks Wolfgang L. for reporting and tracking it down. 8761 8762 - fixed docs and code to use "pytest" instead of "py.test" almost everywhere. 8763 Thanks Jurko Gospodnetic for the complete PR. 8764 8765 - fix issue425: mention at end of "py.test -h" that --markers 8766 and --fixtures work according to specified test path (or current dir) 8767 8768 - fix issue413: exceptions with unicode attributes are now printed 8769 correctly also on python2 and with pytest-xdist runs. (the fix 8770 requires py-1.4.20) 8771 8772 - copy, cleanup and integrate py.io capture 8773 from pylib 1.4.20.dev2 (rev 13d9af95547e) 8774 8775 - address issue416: clarify docs as to conftest.py loading semantics 8776 8777 - fix issue429: comparing byte strings with non-ascii chars in assert 8778 expressions now work better. Thanks Floris Bruynooghe. 8779 8780 - make capfd/capsys.capture private, its unused and shouldn't be exposed 8781 8782 8783 2.5.1 (2013-12-17) 8784 ================== 8785 8786 - merge new documentation styling PR from Tobias Bieniek. 8787 8788 - fix issue403: allow parametrize of multiple same-name functions within 8789 a collection node. Thanks Andreas Kloeckner and Alex Gaynor for reporting 8790 and analysis. 8791 8792 - Allow parameterized fixtures to specify the ID of the parameters by 8793 adding an ids argument to pytest.fixture() and pytest.yield_fixture(). 8794 Thanks Floris Bruynooghe. 8795 8796 - fix issue404 by always using the binary xml escape in the junitxml 8797 plugin. Thanks Ronny Pfannschmidt. 8798 8799 - fix issue407: fix addoption docstring to point to argparse instead of 8800 optparse. Thanks Daniel D. Wright. 8801 8802 8803 8804 2.5.0 (2013-12-12) 8805 ================== 8806 8807 - dropped python2.5 from automated release testing of pytest itself 8808 which means it's probably going to break soon (but still works 8809 with this release we believe). 8810 8811 - simplified and fixed implementation for calling finalizers when 8812 parametrized fixtures or function arguments are involved. finalization 8813 is now performed lazily at setup time instead of in the "teardown phase". 8814 While this might sound odd at first, it helps to ensure that we are 8815 correctly handling setup/teardown even in complex code. User-level code 8816 should not be affected unless it's implementing the pytest_runtest_teardown 8817 hook and expecting certain fixture instances are torn down within (very 8818 unlikely and would have been unreliable anyway). 8819 8820 - PR90: add --color=yes|no|auto option to force terminal coloring 8821 mode ("auto" is default). Thanks Marc Abramowitz. 8822 8823 - fix issue319 - correctly show unicode in assertion errors. Many 8824 thanks to Floris Bruynooghe for the complete PR. Also means 8825 we depend on py>=1.4.19 now. 8826 8827 - fix issue396 - correctly sort and finalize class-scoped parametrized 8828 tests independently from number of methods on the class. 8829 8830 - refix issue323 in a better way -- parametrization should now never 8831 cause Runtime Recursion errors because the underlying algorithm 8832 for re-ordering tests per-scope/per-fixture is not recursive 8833 anymore (it was tail-call recursive before which could lead 8834 to problems for more than >966 non-function scoped parameters). 8835 8836 - fix issue290 - there is preliminary support now for parametrizing 8837 with repeated same values (sometimes useful to test if calling 8838 a second time works as with the first time). 8839 8840 - close issue240 - document precisely how pytest module importing 8841 works, discuss the two common test directory layouts, and how it 8842 interacts with :pep:`420`\-namespace packages. 8843 8844 - fix issue246 fix finalizer order to be LIFO on independent fixtures 8845 depending on a parametrized higher-than-function scoped fixture. 8846 (was quite some effort so please bear with the complexity of this sentence :) 8847 Thanks Ralph Schmitt for the precise failure example. 8848 8849 - fix issue244 by implementing special index for parameters to only use 8850 indices for parametrized test ids 8851 8852 - fix issue287 by running all finalizers but saving the exception 8853 from the first failing finalizer and re-raising it so teardown will 8854 still have failed. We reraise the first failing exception because 8855 it might be the cause for other finalizers to fail. 8856 8857 - fix ordering when mock.patch or other standard decorator-wrappings 8858 are used with test methods. This fixes issue346 and should 8859 help with random "xdist" collection failures. Thanks to 8860 Ronny Pfannschmidt and Donald Stufft for helping to isolate it. 8861 8862 - fix issue357 - special case "-k" expressions to allow for 8863 filtering with simple strings that are not valid python expressions. 8864 Examples: "-k 1.3" matches all tests parametrized with 1.3. 8865 "-k None" filters all tests that have "None" in their name 8866 and conversely "-k 'not None'". 8867 Previously these examples would raise syntax errors. 8868 8869 - fix issue384 by removing the trial support code 8870 since the unittest compat enhancements allow 8871 trial to handle it on its own 8872 8873 - don't hide an ImportError when importing a plugin produces one. 8874 fixes issue375. 8875 8876 - fix issue275 - allow usefixtures and autouse fixtures 8877 for running doctest text files. 8878 8879 - fix issue380 by making --resultlog only rely on longrepr instead 8880 of the "reprcrash" attribute which only exists sometimes. 8881 8882 - address issue122: allow @pytest.fixture(params=iterator) by exploding 8883 into a list early on. 8884 8885 - fix pexpect-3.0 compatibility for pytest's own tests. 8886 (fixes issue386) 8887 8888 - allow nested parametrize-value markers, thanks James Lan for the PR. 8889 8890 - fix unicode handling with new monkeypatch.setattr(import_path, value) 8891 API. Thanks Rob Dennis. Fixes issue371. 8892 8893 - fix unicode handling with junitxml, fixes issue368. 8894 8895 - In assertion rewriting mode on Python 2, fix the detection of coding 8896 cookies. See issue #330. 8897 8898 - make "--runxfail" turn imperative pytest.xfail calls into no ops 8899 (it already did neutralize pytest.mark.xfail markers) 8900 8901 - refine pytest / pkg_resources interactions: The AssertionRewritingHook 8902 :pep:`302` compliant loader now registers itself with setuptools/pkg_resources 8903 properly so that the pkg_resources.resource_stream method works properly. 8904 Fixes issue366. Thanks for the investigations and full PR to Jason R. Coombs. 8905 8906 - pytestconfig fixture is now session-scoped as it is the same object during the 8907 whole test run. Fixes issue370. 8908 8909 - avoid one surprising case of marker malfunction/confusion:: 8910 8911 @pytest.mark.some(lambda arg: ...) 8912 def test_function(): 8913 8914 would not work correctly because pytest assumes @pytest.mark.some 8915 gets a function to be decorated already. We now at least detect if this 8916 arg is a lambda and thus the example will work. Thanks Alex Gaynor 8917 for bringing it up. 8918 8919 - xfail a test on pypy that checks wrong encoding/ascii (pypy does 8920 not error out). fixes issue385. 8921 8922 - internally make varnames() deal with classes's __init__, 8923 although it's not needed by pytest itself atm. Also 8924 fix caching. Fixes issue376. 8925 8926 - fix issue221 - handle importing of namespace-package with no 8927 __init__.py properly. 8928 8929 - refactor internal FixtureRequest handling to avoid monkeypatching. 8930 One of the positive user-facing effects is that the "request" object 8931 can now be used in closures. 8932 8933 - fixed version comparison in pytest.importskip(modname, minverstring) 8934 8935 - fix issue377 by clarifying in the nose-compat docs that pytest 8936 does not duplicate the unittest-API into the "plain" namespace. 8937 8938 - fix verbose reporting for @mock'd test functions 8939 8940 2.4.2 (2013-10-04) 8941 ================== 8942 8943 - on Windows require colorama and a newer py lib so that py.io.TerminalWriter() 8944 now uses colorama instead of its own ctypes hacks. (fixes issue365) 8945 thanks Paul Moore for bringing it up. 8946 8947 - fix "-k" matching of tests where "repr" and "attr" and other names would 8948 cause wrong matches because of an internal implementation quirk 8949 (don't ask) which is now properly implemented. fixes issue345. 8950 8951 - avoid tmpdir fixture to create too long filenames especially 8952 when parametrization is used (issue354) 8953 8954 - fix pytest-pep8 and pytest-flakes / pytest interactions 8955 (collection names in mark plugin was assuming an item always 8956 has a function which is not true for those plugins etc.) 8957 Thanks Andi Zeidler. 8958 8959 - introduce node.get_marker/node.add_marker API for plugins 8960 like pytest-pep8 and pytest-flakes to avoid the messy 8961 details of the node.keywords pseudo-dicts. Adapted 8962 docs. 8963 8964 - remove attempt to "dup" stdout at startup as it's icky. 8965 the normal capturing should catch enough possibilities 8966 of tests messing up standard FDs. 8967 8968 - add pluginmanager.do_configure(config) as a link to 8969 config.do_configure() for plugin-compatibility 8970 8971 2.4.1 (2013-10-02) 8972 ================== 8973 8974 - When using parser.addoption() unicode arguments to the 8975 "type" keyword should also be converted to the respective types. 8976 thanks Floris Bruynooghe, @dnozay. (fixes issue360 and issue362) 8977 8978 - fix dotted filename completion when using argcomplete 8979 thanks Anthon van der Neuth. (fixes issue361) 8980 8981 - fix regression when a 1-tuple ("arg",) is used for specifying 8982 parametrization (the values of the parametrization were passed 8983 nested in a tuple). Thanks Donald Stufft. 8984 8985 - merge doc typo fixes, thanks Andy Dirnberger 8986 8987 2.4 8988 === 8989 8990 known incompatibilities: 8991 8992 - if calling --genscript from python2.7 or above, you only get a 8993 standalone script which works on python2.7 or above. Use Python2.6 8994 to also get a python2.5 compatible version. 8995 8996 - all xunit-style teardown methods (nose-style, pytest-style, 8997 unittest-style) will not be called if the corresponding setup method failed, 8998 see issue322 below. 8999 9000 - the pytest_plugin_unregister hook wasn't ever properly called 9001 and there is no known implementation of the hook - so it got removed. 9002 9003 - pytest.fixture-decorated functions cannot be generators (i.e. use 9004 yield) anymore. This change might be reversed in 2.4.1 if it causes 9005 unforeseen real-life issues. However, you can always write and return 9006 an inner function/generator and change the fixture consumer to iterate 9007 over the returned generator. This change was done in lieu of the new 9008 ``pytest.yield_fixture`` decorator, see below. 9009 9010 new features: 9011 9012 - experimentally introduce a new ``pytest.yield_fixture`` decorator 9013 which accepts exactly the same parameters as pytest.fixture but 9014 mandates a ``yield`` statement instead of a ``return statement`` from 9015 fixture functions. This allows direct integration with "with-style" 9016 context managers in fixture functions and generally avoids registering 9017 of finalization callbacks in favour of treating the "after-yield" as 9018 teardown code. Thanks Andreas Pelme, Vladimir Keleshev, Floris 9019 Bruynooghe, Ronny Pfannschmidt and many others for discussions. 9020 9021 - allow boolean expression directly with skipif/xfail 9022 if a "reason" is also specified. Rework skipping documentation 9023 to recommend "condition as booleans" because it prevents surprises 9024 when importing markers between modules. Specifying conditions 9025 as strings will remain fully supported. 9026 9027 - reporting: color the last line red or green depending if 9028 failures/errors occurred or everything passed. thanks Christian 9029 Theunert. 9030 9031 - make "import pdb ; pdb.set_trace()" work natively wrt capturing (no 9032 "-s" needed anymore), making ``pytest.set_trace()`` a mere shortcut. 9033 9034 - fix issue181: --pdb now also works on collect errors (and 9035 on internal errors) . This was implemented by a slight internal 9036 refactoring and the introduction of a new hook 9037 ``pytest_exception_interact`` hook (see next item). 9038 9039 - fix issue341: introduce new experimental hook for IDEs/terminals to 9040 intercept debugging: ``pytest_exception_interact(node, call, report)``. 9041 9042 - new monkeypatch.setattr() variant to provide a shorter 9043 invocation for patching out classes/functions from modules: 9044 9045 monkeypatch.setattr("requests.get", myfunc) 9046 9047 will replace the "get" function of the "requests" module with ``myfunc``. 9048 9049 - fix issue322: tearDownClass is not run if setUpClass failed. Thanks 9050 Mathieu Agopian for the initial fix. Also make all of pytest/nose 9051 finalizer mimic the same generic behaviour: if a setupX exists and 9052 fails, don't run teardownX. This internally introduces a new method 9053 "node.addfinalizer()" helper which can only be called during the setup 9054 phase of a node. 9055 9056 - simplify pytest.mark.parametrize() signature: allow to pass a 9057 CSV-separated string to specify argnames. For example: 9058 ``pytest.mark.parametrize("input,expected", [(1,2), (2,3)])`` 9059 works as well as the previous: 9060 ``pytest.mark.parametrize(("input", "expected"), ...)``. 9061 9062 - add support for setUpModule/tearDownModule detection, thanks Brian Okken. 9063 9064 - integrate tab-completion on options through use of "argcomplete". 9065 Thanks Anthon van der Neut for the PR. 9066 9067 - change option names to be hyphen-separated long options but keep the 9068 old spelling backward compatible. py.test -h will only show the 9069 hyphenated version, for example "--collect-only" but "--collectonly" 9070 will remain valid as well (for backward-compat reasons). Many thanks to 9071 Anthon van der Neut for the implementation and to Hynek Schlawack for 9072 pushing us. 9073 9074 - fix issue 308 - allow to mark/xfail/skip individual parameter sets 9075 when parametrizing. Thanks Brianna Laugher. 9076 9077 - call new experimental pytest_load_initial_conftests hook to allow 9078 3rd party plugins to do something before a conftest is loaded. 9079 9080 Bug fixes: 9081 9082 - fix issue358 - capturing options are now parsed more properly 9083 by using a new parser.parse_known_args method. 9084 9085 - pytest now uses argparse instead of optparse (thanks Anthon) which 9086 means that "argparse" is added as a dependency if installing into python2.6 9087 environments or below. 9088 9089 - fix issue333: fix a case of bad unittest/pytest hook interaction. 9090 9091 - PR27: correctly handle nose.SkipTest during collection. Thanks 9092 Antonio Cuni, Ronny Pfannschmidt. 9093 9094 - fix issue355: junitxml puts name="pytest" attribute to testsuite tag. 9095 9096 - fix issue336: autouse fixture in plugins should work again. 9097 9098 - fix issue279: improve object comparisons on assertion failure 9099 for standard datatypes and recognise collections.abc. Thanks to 9100 Brianna Laugher and Mathieu Agopian. 9101 9102 - fix issue317: assertion rewriter support for the is_package method 9103 9104 - fix issue335: document py.code.ExceptionInfo() object returned 9105 from pytest.raises(), thanks Mathieu Agopian. 9106 9107 - remove implicit distribute_setup support from setup.py. 9108 9109 - fix issue305: ignore any problems when writing pyc files. 9110 9111 - SO-17664702: call fixture finalizers even if the fixture function 9112 partially failed (finalizers would not always be called before) 9113 9114 - fix issue320 - fix class scope for fixtures when mixed with 9115 module-level functions. Thanks Anatoly Bubenkoff. 9116 9117 - you can specify "-q" or "-qq" to get different levels of "quieter" 9118 reporting (thanks Katarzyna Jachim) 9119 9120 - fix issue300 - Fix order of conftest loading when starting py.test 9121 in a subdirectory. 9122 9123 - fix issue323 - sorting of many module-scoped arg parametrizations 9124 9125 - make sessionfinish hooks execute with the same cwd-context as at 9126 session start (helps fix plugin behaviour which write output files 9127 with relative path such as pytest-cov) 9128 9129 - fix issue316 - properly reference collection hooks in docs 9130 9131 - fix issue 306 - cleanup of -k/-m options to only match markers/test 9132 names/keywords respectively. Thanks Wouter van Ackooy. 9133 9134 - improved doctest counting for doctests in python modules -- 9135 files without any doctest items will not show up anymore 9136 and doctest examples are counted as separate test items. 9137 thanks Danilo Bellini. 9138 9139 - fix issue245 by depending on the released py-1.4.14 9140 which fixes py.io.dupfile to work with files with no 9141 mode. Thanks Jason R. Coombs. 9142 9143 - fix junitxml generation when test output contains control characters, 9144 addressing issue267, thanks Jaap Broekhuizen 9145 9146 - fix issue338: honor --tb style for setup/teardown errors as well. Thanks Maho. 9147 9148 - fix issue307 - use yaml.safe_load in example, thanks Mark Eichin. 9149 9150 - better parametrize error messages, thanks Brianna Laugher 9151 9152 - pytest_terminal_summary(terminalreporter) hooks can now use 9153 ".section(title)" and ".line(msg)" methods to print extra 9154 information at the end of a test run. 9155 9156 2.3.5 (2013-04-30) 9157 ================== 9158 9159 - fix issue169: respect --tb=style with setup/teardown errors as well. 9160 9161 - never consider a fixture function for test function collection 9162 9163 - allow re-running of test items / helps to fix pytest-reruntests plugin 9164 and also help to keep less fixture/resource references alive 9165 9166 - put captured stdout/stderr into junitxml output even for passing tests 9167 (thanks Adam Goucher) 9168 9169 - Issue 265 - integrate nose setup/teardown with setupstate 9170 so it doesn't try to teardown if it did not setup 9171 9172 - issue 271 - don't write junitxml on worker nodes 9173 9174 - Issue 274 - don't try to show full doctest example 9175 when doctest does not know the example location 9176 9177 - issue 280 - disable assertion rewriting on buggy CPython 2.6.0 9178 9179 - inject "getfixture()" helper to retrieve fixtures from doctests, 9180 thanks Andreas Zeidler 9181 9182 - issue 259 - when assertion rewriting, be consistent with the default 9183 source encoding of ASCII on Python 2 9184 9185 - issue 251 - report a skip instead of ignoring classes with init 9186 9187 - issue250 unicode/str mixes in parametrization names and values now works 9188 9189 - issue257, assertion-triggered compilation of source ending in a 9190 comment line doesn't blow up in python2.5 (fixed through py>=1.4.13.dev6) 9191 9192 - fix --genscript option to generate standalone scripts that also 9193 work with python3.3 (importer ordering) 9194 9195 - issue171 - in assertion rewriting, show the repr of some 9196 global variables 9197 9198 - fix option help for "-k" 9199 9200 - move long description of distribution into README.rst 9201 9202 - improve docstring for metafunc.parametrize() 9203 9204 - fix bug where using capsys with pytest.set_trace() in a test 9205 function would break when looking at capsys.readouterr() 9206 9207 - allow to specify prefixes starting with "_" when 9208 customizing python_functions test discovery. (thanks Graham Horler) 9209 9210 - improve PYTEST_DEBUG tracing output by putting 9211 extra data on a new lines with additional indent 9212 9213 - ensure OutcomeExceptions like skip/fail have initialized exception attributes 9214 9215 - issue 260 - don't use nose special setup on plain unittest cases 9216 9217 - fix issue134 - print the collect errors that prevent running specified test items 9218 9219 - fix issue266 - accept unicode in MarkEvaluator expressions 9220 9221 2.3.4 (2012-11-20) 9222 ================== 9223 9224 - yielded test functions will now have autouse-fixtures active but 9225 cannot accept fixtures as funcargs - it's anyway recommended to 9226 rather use the post-2.0 parametrize features instead of yield, see: 9227 http://pytest.org/en/stable/example/how-to/parametrize.html 9228 - fix autouse-issue where autouse-fixtures would not be discovered 9229 if defined in an a/conftest.py file and tests in a/tests/test_some.py 9230 - fix issue226 - LIFO ordering for fixture teardowns 9231 - fix issue224 - invocations with >256 char arguments now work 9232 - fix issue91 - add/discuss package/directory level setups in example 9233 - allow to dynamically define markers via 9234 item.keywords[...]=assignment integrating with "-m" option 9235 - make "-k" accept an expressions the same as with "-m" so that one 9236 can write: -k "name1 or name2" etc. This is a slight incompatibility 9237 if you used special syntax like "TestClass.test_method" which you now 9238 need to write as -k "TestClass and test_method" to match a certain 9239 method in a certain test class. 9240 9241 2.3.3 (2012-11-06) 9242 ================== 9243 9244 - fix issue214 - parse modules that contain special objects like e. g. 9245 flask's request object which blows up on getattr access if no request 9246 is active. thanks Thomas Waldmann. 9247 9248 - fix issue213 - allow to parametrize with values like numpy arrays that 9249 do not support an __eq__ operator 9250 9251 - fix issue215 - split test_python.org into multiple files 9252 9253 - fix issue148 - @unittest.skip on classes is now recognized and avoids 9254 calling setUpClass/tearDownClass, thanks Pavel Repin 9255 9256 - fix issue209 - reintroduce python2.4 support by depending on newer 9257 pylib which re-introduced statement-finding for pre-AST interpreters 9258 9259 - nose support: only call setup if it's a callable, thanks Andrew 9260 Taumoefolau 9261 9262 - fix issue219 - add py2.4-3.3 classifiers to TROVE list 9263 9264 - in tracebacks *,** arg values are now shown next to normal arguments 9265 (thanks Manuel Jacob) 9266 9267 - fix issue217 - support mock.patch with pytest's fixtures - note that 9268 you need either mock-1.0.1 or the python3.3 builtin unittest.mock. 9269 9270 - fix issue127 - improve documentation for pytest_addoption() and 9271 add a ``config.getoption(name)`` helper function for consistency. 9272 9273 2.3.2 (2012-10-25) 9274 ================== 9275 9276 - fix issue208 and fix issue29 use new py version to avoid long pauses 9277 when printing tracebacks in long modules 9278 9279 - fix issue205 - conftests in subdirs customizing 9280 pytest_pycollect_makemodule and pytest_pycollect_makeitem 9281 now work properly 9282 9283 - fix teardown-ordering for parametrized setups 9284 9285 - fix issue127 - better documentation for pytest_addoption 9286 and related objects. 9287 9288 - fix unittest behaviour: TestCase.runtest only called if there are 9289 test methods defined 9290 9291 - improve trial support: don't collect its empty 9292 unittest.TestCase.runTest() method 9293 9294 - "python setup.py test" now works with pytest itself 9295 9296 - fix/improve internal/packaging related bits: 9297 9298 - exception message check of test_nose.py now passes on python33 as well 9299 9300 - issue206 - fix test_assertrewrite.py to work when a global 9301 PYTHONDONTWRITEBYTECODE=1 is present 9302 9303 - add tox.ini to pytest distribution so that ignore-dirs and others config 9304 bits are properly distributed for maintainers who run pytest-own tests 9305 9306 2.3.1 (2012-10-20) 9307 ================== 9308 9309 - fix issue202 - fix regression: using "self" from fixture functions now 9310 works as expected (it's the same "self" instance that a test method 9311 which uses the fixture sees) 9312 9313 - skip pexpect using tests (test_pdb.py mostly) on freebsd* systems 9314 due to pexpect not supporting it properly (hanging) 9315 9316 - link to web pages from --markers output which provides help for 9317 pytest.mark.* usage. 9318 9319 2.3.0 (2012-10-19) 9320 ================== 9321 9322 - fix issue202 - better automatic names for parametrized test functions 9323 - fix issue139 - introduce @pytest.fixture which allows direct scoping 9324 and parametrization of funcarg factories. 9325 - fix issue198 - conftest fixtures were not found on windows32 in some 9326 circumstances with nested directory structures due to path manipulation issues 9327 - fix issue193 skip test functions with were parametrized with empty 9328 parameter sets 9329 - fix python3.3 compat, mostly reporting bits that previously depended 9330 on dict ordering 9331 - introduce re-ordering of tests by resource and parametrization setup 9332 which takes precedence to the usual file-ordering 9333 - fix issue185 monkeypatching time.time does not cause pytest to fail 9334 - fix issue172 duplicate call of pytest.fixture decoratored setup_module 9335 functions 9336 - fix junitxml=path construction so that if tests change the 9337 current working directory and the path is a relative path 9338 it is constructed correctly from the original current working dir. 9339 - fix "python setup.py test" example to cause a proper "errno" return 9340 - fix issue165 - fix broken doc links and mention stackoverflow for FAQ 9341 - catch unicode-issues when writing failure representations 9342 to terminal to prevent the whole session from crashing 9343 - fix xfail/skip confusion: a skip-mark or an imperative pytest.skip 9344 will now take precedence before xfail-markers because we 9345 can't determine xfail/xpass status in case of a skip. see also: 9346 http://stackoverflow.com/questions/11105828/in-py-test-when-i-explicitly-skip-a-test-that-is-marked-as-xfail-how-can-i-get 9347 9348 - always report installed 3rd party plugins in the header of a test run 9349 9350 - fix issue160: a failing setup of an xfail-marked tests should 9351 be reported as xfail (not xpass) 9352 9353 - fix issue128: show captured output when capsys/capfd are used 9354 9355 - fix issue179: properly show the dependency chain of factories 9356 9357 - pluginmanager.register(...) now raises ValueError if the 9358 plugin has been already registered or the name is taken 9359 9360 - fix issue159: improve https://docs.pytest.org/en/6.0.1/faq.html 9361 especially with respect to the "magic" history, also mention 9362 pytest-django, trial and unittest integration. 9363 9364 - make request.keywords and node.keywords writable. All descendant 9365 collection nodes will see keyword values. Keywords are dictionaries 9366 containing markers and other info. 9367 9368 - fix issue 178: xml binary escapes are now wrapped in py.xml.raw 9369 9370 - fix issue 176: correctly catch the builtin AssertionError 9371 even when we replaced AssertionError with a subclass on the 9372 python level 9373 9374 - factory discovery no longer fails with magic global callables 9375 that provide no sane __code__ object (mock.call for example) 9376 9377 - fix issue 182: testdir.inprocess_run now considers passed plugins 9378 9379 - fix issue 188: ensure sys.exc_info is clear on python2 9380 before calling into a test 9381 9382 - fix issue 191: add unittest TestCase runTest method support 9383 - fix issue 156: monkeypatch correctly handles class level descriptors 9384 9385 - reporting refinements: 9386 9387 - pytest_report_header now receives a "startdir" so that 9388 you can use startdir.bestrelpath(yourpath) to show 9389 nice relative path 9390 9391 - allow plugins to implement both pytest_report_header and 9392 pytest_sessionstart (sessionstart is invoked first). 9393 9394 - don't show deselected reason line if there is none 9395 9396 - py.test -vv will show all of assert comparisons instead of truncating 9397 9398 2.2.4 (2012-05-22) 9399 ================== 9400 9401 - fix error message for rewritten assertions involving the % operator 9402 - fix issue 126: correctly match all invalid xml characters for junitxml 9403 binary escape 9404 - fix issue with unittest: now @unittest.expectedFailure markers should 9405 be processed correctly (you can also use @pytest.mark markers) 9406 - document integration with the extended distribute/setuptools test commands 9407 - fix issue 140: properly get the real functions 9408 of bound classmethods for setup/teardown_class 9409 - fix issue #141: switch from the deceased paste.pocoo.org to bpaste.net 9410 - fix issue #143: call unconfigure/sessionfinish always when 9411 configure/sessionstart where called 9412 - fix issue #144: better mangle test ids to junitxml classnames 9413 - upgrade distribute_setup.py to 0.6.27 9414 9415 2.2.3 (2012-02-05) 9416 ================== 9417 9418 - fix uploaded package to only include necessary files 9419 9420 2.2.2 (2012-02-05) 9421 ================== 9422 9423 - fix issue101: wrong args to unittest.TestCase test function now 9424 produce better output 9425 - fix issue102: report more useful errors and hints for when a 9426 test directory was renamed and some pyc/__pycache__ remain 9427 - fix issue106: allow parametrize to be applied multiple times 9428 e.g. from module, class and at function level. 9429 - fix issue107: actually perform session scope finalization 9430 - don't check in parametrize if indirect parameters are funcarg names 9431 - add chdir method to monkeypatch funcarg 9432 - fix crash resulting from calling monkeypatch undo a second time 9433 - fix issue115: make --collectonly robust against early failure 9434 (missing files/directories) 9435 - "-qq --collectonly" now shows only files and the number of tests in them 9436 - "-q --collectonly" now shows test ids 9437 - allow adding of attributes to test reports such that it also works 9438 with distributed testing (no upgrade of pytest-xdist needed) 9439 9440 2.2.1 (2011-12-16) 9441 ================== 9442 9443 - fix issue99 (in pytest and py) internallerrors with resultlog now 9444 produce better output - fixed by normalizing pytest_internalerror 9445 input arguments. 9446 - fix issue97 / traceback issues (in pytest and py) improve traceback output 9447 in conjunction with jinja2 and cython which hack tracebacks 9448 - fix issue93 (in pytest and pytest-xdist) avoid "delayed teardowns": 9449 the final test in a test node will now run its teardown directly 9450 instead of waiting for the end of the session. Thanks Dave Hunt for 9451 the good reporting and feedback. The pytest_runtest_protocol as well 9452 as the pytest_runtest_teardown hooks now have "nextitem" available 9453 which will be None indicating the end of the test run. 9454 - fix collection crash due to unknown-source collected items, thanks 9455 to Ralf Schmitt (fixed by depending on a more recent pylib) 9456 9457 2.2.0 (2011-11-18) 9458 ================== 9459 9460 - fix issue90: introduce eager tearing down of test items so that 9461 teardown function are called earlier. 9462 - add an all-powerful metafunc.parametrize function which allows to 9463 parametrize test function arguments in multiple steps and therefore 9464 from independent plugins and places. 9465 - add a @pytest.mark.parametrize helper which allows to easily 9466 call a test function with different argument values 9467 - Add examples to the "parametrize" example page, including a quick port 9468 of Test scenarios and the new parametrize function and decorator. 9469 - introduce registration for "pytest.mark.*" helpers via ini-files 9470 or through plugin hooks. Also introduce a "--strict" option which 9471 will treat unregistered markers as errors 9472 allowing to avoid typos and maintain a well described set of markers 9473 for your test suite. See examples at http://pytest.org/en/stable/how-to/mark.html 9474 and its links. 9475 - issue50: introduce "-m marker" option to select tests based on markers 9476 (this is a stricter and more predictable version of '-k' in that "-m" 9477 only matches complete markers and has more obvious rules for and/or 9478 semantics. 9479 - new feature to help optimizing the speed of your tests: 9480 --durations=N option for displaying N slowest test calls 9481 and setup/teardown methods. 9482 - fix issue87: --pastebin now works with python3 9483 - fix issue89: --pdb with unexpected exceptions in doctest work more sensibly 9484 - fix and cleanup pytest's own test suite to not leak FDs 9485 - fix issue83: link to generated funcarg list 9486 - fix issue74: pyarg module names are now checked against imp.find_module false positives 9487 - fix compatibility with twisted/trial-11.1.0 use cases 9488 - simplify Node.listchain 9489 - simplify junitxml output code by relying on py.xml 9490 - add support for skip properties on unittest classes and functions 9491 9492 2.1.3 (2011-10-18) 9493 ================== 9494 9495 - fix issue79: assertion rewriting failed on some comparisons in boolops 9496 - correctly handle zero length arguments (a la pytest '') 9497 - fix issue67 / junitxml now contains correct test durations, thanks ronny 9498 - fix issue75 / skipping test failure on jython 9499 - fix issue77 / Allow assertrepr_compare hook to apply to a subset of tests 9500 9501 2.1.2 (2011-09-24) 9502 ================== 9503 9504 - fix assertion rewriting on files with windows newlines on some Python versions 9505 - refine test discovery by package/module name (--pyargs), thanks Florian Mayer 9506 - fix issue69 / assertion rewriting fixed on some boolean operations 9507 - fix issue68 / packages now work with assertion rewriting 9508 - fix issue66: use different assertion rewriting caches when the -O option is passed 9509 - don't try assertion rewriting on Jython, use reinterp 9510 9511 2.1.1 9512 ===== 9513 9514 - fix issue64 / pytest.set_trace now works within pytest_generate_tests hooks 9515 - fix issue60 / fix error conditions involving the creation of __pycache__ 9516 - fix issue63 / assertion rewriting on inserts involving strings containing '%' 9517 - fix assertion rewriting on calls with a ** arg 9518 - don't cache rewritten modules if bytecode generation is disabled 9519 - fix assertion rewriting in read-only directories 9520 - fix issue59: provide system-out/err tags for junitxml output 9521 - fix issue61: assertion rewriting on boolean operations with 3 or more operands 9522 - you can now build a man page with "cd doc ; make man" 9523 9524 2.1.0 (2011-07-09) 9525 ================== 9526 9527 - fix issue53 call nosestyle setup functions with correct ordering 9528 - fix issue58 and issue59: new assertion code fixes 9529 - merge Benjamin's assertionrewrite branch: now assertions 9530 for test modules on python 2.6 and above are done by rewriting 9531 the AST and saving the pyc file before the test module is imported. 9532 see doc/assert.txt for more info. 9533 - fix issue43: improve doctests with better traceback reporting on 9534 unexpected exceptions 9535 - fix issue47: timing output in junitxml for test cases is now correct 9536 - fix issue48: typo in MarkInfo repr leading to exception 9537 - fix issue49: avoid confusing error when initialization partially fails 9538 - fix issue44: env/username expansion for junitxml file path 9539 - show releaselevel information in test runs for pypy 9540 - reworked doc pages for better navigation and PDF generation 9541 - report KeyboardInterrupt even if interrupted during session startup 9542 - fix issue 35 - provide PDF doc version and download link from index page 9543 9544 2.0.3 (2011-05-11) 9545 ================== 9546 9547 - fix issue38: nicer tracebacks on calls to hooks, particularly early 9548 configure/sessionstart ones 9549 9550 - fix missing skip reason/meta information in junitxml files, reported 9551 via http://lists.idyll.org/pipermail/testing-in-python/2011-March/003928.html 9552 9553 - fix issue34: avoid collection failure with "test" prefixed classes 9554 deriving from object. 9555 9556 - don't require zlib (and other libs) for genscript plugin without 9557 --genscript actually being used. 9558 9559 - speed up skips (by not doing a full traceback representation 9560 internally) 9561 9562 - fix issue37: avoid invalid characters in junitxml's output 9563 9564 2.0.2 (2011-03-09) 9565 ================== 9566 9567 - tackle issue32 - speed up test runs of very quick test functions 9568 by reducing the relative overhead 9569 9570 - fix issue30 - extended xfail/skipif handling and improved reporting. 9571 If you have a syntax error in your skip/xfail 9572 expressions you now get nice error reports. 9573 9574 Also you can now access module globals from xfail/skipif 9575 expressions so that this for example works now:: 9576 9577 import pytest 9578 import mymodule 9579 @pytest.mark.skipif("mymodule.__version__[0] == "1") 9580 def test_function(): 9581 pass 9582 9583 This will not run the test function if the module's version string 9584 does not start with a "1". Note that specifying a string instead 9585 of a boolean expressions allows py.test to report meaningful information 9586 when summarizing a test run as to what conditions lead to skipping 9587 (or xfail-ing) tests. 9588 9589 - fix issue28 - setup_method and pytest_generate_tests work together 9590 The setup_method fixture method now gets called also for 9591 test function invocations generated from the pytest_generate_tests 9592 hook. 9593 9594 - fix issue27 - collectonly and keyword-selection (-k) now work together 9595 Also, if you do "py.test --collectonly -q" you now get a flat list 9596 of test ids that you can use to paste to the py.test commandline 9597 in order to execute a particular test. 9598 9599 - fix issue25 avoid reported problems with --pdb and python3.2/encodings output 9600 9601 - fix issue23 - tmpdir argument now works on Python3.2 and WindowsXP 9602 Starting with Python3.2 os.symlink may be supported. By requiring 9603 a newer py lib version the py.path.local() implementation acknowledges 9604 this. 9605 9606 - fixed typos in the docs (thanks Victor Garcia, Brianna Laugher) and particular 9607 thanks to Laura Creighton who also reviewed parts of the documentation. 9608 9609 - fix slightly wrong output of verbose progress reporting for classes 9610 (thanks Amaury) 9611 9612 - more precise (avoiding of) deprecation warnings for node.Class|Function accesses 9613 9614 - avoid std unittest assertion helper code in tracebacks (thanks Ronny) 9615 9616 2.0.1 (2011-02-07) 9617 ================== 9618 9619 - refine and unify initial capturing so that it works nicely 9620 even if the logging module is used on an early-loaded conftest.py 9621 file or plugin. 9622 - allow to omit "()" in test ids to allow for uniform test ids 9623 as produced by Alfredo's nice pytest.vim plugin. 9624 - fix issue12 - show plugin versions with "--version" and 9625 "--traceconfig" and also document how to add extra information 9626 to reporting test header 9627 - fix issue17 (import-* reporting issue on python3) by 9628 requiring py>1.4.0 (1.4.1 is going to include it) 9629 - fix issue10 (numpy arrays truth checking) by refining 9630 assertion interpretation in py lib 9631 - fix issue15: make nose compatibility tests compatible 9632 with python3 (now that nose-1.0 supports python3) 9633 - remove somewhat surprising "same-conftest" detection because 9634 it ignores conftest.py when they appear in several subdirs. 9635 - improve assertions ("not in"), thanks Floris Bruynooghe 9636 - improve behaviour/warnings when running on top of "python -OO" 9637 (assertions and docstrings are turned off, leading to potential 9638 false positives) 9639 - introduce a pytest_cmdline_processargs(args) hook 9640 to allow dynamic computation of command line arguments. 9641 This fixes a regression because py.test prior to 2.0 9642 allowed to set command line options from conftest.py 9643 files which so far pytest-2.0 only allowed from ini-files now. 9644 - fix issue7: assert failures in doctest modules. 9645 unexpected failures in doctests will not generally 9646 show nicer, i.e. within the doctest failing context. 9647 - fix issue9: setup/teardown functions for an xfail-marked 9648 test will report as xfail if they fail but report as normally 9649 passing (not xpassing) if they succeed. This only is true 9650 for "direct" setup/teardown invocations because teardown_class/ 9651 teardown_module cannot closely relate to a single test. 9652 - fix issue14: no logging errors at process exit 9653 - refinements to "collecting" output on non-ttys 9654 - refine internal plugin registration and --traceconfig output 9655 - introduce a mechanism to prevent/unregister plugins from the 9656 command line, see http://pytest.org/en/stable/how-to/plugins.html#cmdunregister 9657 - activate resultlog plugin by default 9658 - fix regression wrt yielded tests which due to the 9659 collection-before-running semantics were not 9660 setup as with pytest 1.3.4. Note, however, that 9661 the recommended and much cleaner way to do test 9662 parameterization remains the "pytest_generate_tests" 9663 mechanism, see the docs. 9664 9665 2.0.0 (2010-11-25) 9666 ================== 9667 9668 - pytest-2.0 is now its own package and depends on pylib-2.0 9669 - new ability: python -m pytest / python -m pytest.main ability 9670 - new python invocation: pytest.main(args, plugins) to load 9671 some custom plugins early. 9672 - try harder to run unittest test suites in a more compatible manner 9673 by deferring setup/teardown semantics to the unittest package. 9674 also work harder to run twisted/trial and Django tests which 9675 should now basically work by default. 9676 - introduce a new way to set config options via ini-style files, 9677 by default setup.cfg and tox.ini files are searched. The old 9678 ways (certain environment variables, dynamic conftest.py reading 9679 is removed). 9680 - add a new "-q" option which decreases verbosity and prints a more 9681 nose/unittest-style "dot" output. 9682 - fix issue135 - marks now work with unittest test cases as well 9683 - fix issue126 - introduce py.test.set_trace() to trace execution via 9684 PDB during the running of tests even if capturing is ongoing. 9685 - fix issue123 - new "python -m py.test" invocation for py.test 9686 (requires Python 2.5 or above) 9687 - fix issue124 - make reporting more resilient against tests opening 9688 files on filedescriptor 1 (stdout). 9689 - fix issue109 - sibling conftest.py files will not be loaded. 9690 (and Directory collectors cannot be customized anymore from a Directory's 9691 conftest.py - this needs to happen at least one level up). 9692 - introduce (customizable) assertion failure representations and enhance 9693 output on assertion failures for comparisons and other cases (Floris Bruynooghe) 9694 - nose-plugin: pass through type-signature failures in setup/teardown 9695 functions instead of not calling them (Ed Singleton) 9696 - remove py.test.collect.Directory (follows from a major refactoring 9697 and simplification of the collection process) 9698 - majorly reduce py.test core code, shift function/python testing to own plugin 9699 - fix issue88 (finding custom test nodes from command line arg) 9700 - refine 'tmpdir' creation, will now create basenames better associated 9701 with test names (thanks Ronny) 9702 - "xpass" (unexpected pass) tests don't cause exitcode!=0 9703 - fix issue131 / issue60 - importing doctests in __init__ files used as namespace packages 9704 - fix issue93 stdout/stderr is captured while importing conftest.py 9705 - fix bug: unittest collected functions now also can have "pytestmark" 9706 applied at class/module level 9707 - add ability to use "class" level for cached_setup helper 9708 - fix strangeness: mark.* objects are now immutable, create new instances 9709 9710 1.3.4 (2010-09-14) 9711 ================== 9712 9713 - fix issue111: improve install documentation for windows 9714 - fix issue119: fix custom collectability of __init__.py as a module 9715 - fix issue116: --doctestmodules work with __init__.py files as well 9716 - fix issue115: unify internal exception passthrough/catching/GeneratorExit 9717 - fix issue118: new --tb=native for presenting cpython-standard exceptions 9718 9719 1.3.3 (2010-07-30) 9720 ================== 9721 9722 - fix issue113: assertion representation problem with triple-quoted strings 9723 (and possibly other cases) 9724 - make conftest loading detect that a conftest file with the same 9725 content was already loaded, avoids surprises in nested directory structures 9726 which can be produced e.g. by Hudson. It probably removes the need to use 9727 --confcutdir in most cases. 9728 - fix terminal coloring for win32 9729 (thanks Michael Foord for reporting) 9730 - fix weirdness: make terminal width detection work on stdout instead of stdin 9731 (thanks Armin Ronacher for reporting) 9732 - remove trailing whitespace in all py/text distribution files 9733 9734 1.3.2 (2010-07-08) 9735 ================== 9736 9737 **New features** 9738 9739 - fix issue103: introduce py.test.raises as context manager, examples:: 9740 9741 with py.test.raises(ZeroDivisionError): 9742 x = 0 9743 1 / x 9744 9745 with py.test.raises(RuntimeError) as excinfo: 9746 call_something() 9747 9748 # you may do extra checks on excinfo.value|type|traceback here 9749 9750 (thanks Ronny Pfannschmidt) 9751 9752 - Funcarg factories can now dynamically apply a marker to a 9753 test invocation. This is for example useful if a factory 9754 provides parameters to a test which are expected-to-fail:: 9755 9756 def pytest_funcarg__arg(request): 9757 request.applymarker(py.test.mark.xfail(reason="flaky config")) 9758 ... 9759 9760 def test_function(arg): 9761 ... 9762 9763 - improved error reporting on collection and import errors. This makes 9764 use of a more general mechanism, namely that for custom test item/collect 9765 nodes ``node.repr_failure(excinfo)`` is now uniformly called so that you can 9766 override it to return a string error representation of your choice 9767 which is going to be reported as a (red) string. 9768 9769 - introduce '--junitprefix=STR' option to prepend a prefix 9770 to all reports in the junitxml file. 9771 9772 **Bug fixes** 9773 9774 - make tests and the ``pytest_recwarn`` plugin in particular fully compatible 9775 to Python2.7 (if you use the ``recwarn`` funcarg warnings will be enabled so that 9776 you can properly check for their existence in a cross-python manner). 9777 - refine --pdb: ignore xfailed tests, unify its TB-reporting and 9778 don't display failures again at the end. 9779 - fix assertion interpretation with the ** operator (thanks Benjamin Peterson) 9780 - fix issue105 assignment on the same line as a failing assertion (thanks Benjamin Peterson) 9781 - fix issue104 proper escaping for test names in junitxml plugin (thanks anonymous) 9782 - fix issue57 -f|--looponfail to work with xpassing tests (thanks Ronny) 9783 - fix issue92 collectonly reporter and --pastebin (thanks Benjamin Peterson) 9784 - fix py.code.compile(source) to generate unique filenames 9785 - fix assertion re-interp problems on PyPy, by deferring code 9786 compilation to the (overridable) Frame.eval class. (thanks Amaury Forgeot) 9787 - fix py.path.local.pyimport() to work with directories 9788 - streamline py.path.local.mkdtemp implementation and usage 9789 - don't print empty lines when showing junitxml-filename 9790 - add optional boolean ignore_errors parameter to py.path.local.remove 9791 - fix terminal writing on win32/python2.4 9792 - py.process.cmdexec() now tries harder to return properly encoded unicode objects 9793 on all python versions 9794 - install plain py.test/py.which scripts also for Jython, this helps to 9795 get canonical script paths in virtualenv situations 9796 - make path.bestrelpath(path) return ".", note that when calling 9797 X.bestrelpath the assumption is that X is a directory. 9798 - make initial conftest discovery ignore "--" prefixed arguments 9799 - fix resultlog plugin when used in a multicpu/multihost xdist situation 9800 (thanks Jakub Gustak) 9801 - perform distributed testing related reporting in the xdist-plugin 9802 rather than having dist-related code in the generic py.test 9803 distribution 9804 - fix homedir detection on Windows 9805 - ship distribute_setup.py version 0.6.13 9806 9807 1.3.1 (2010-05-25) 9808 ================== 9809 9810 **New features** 9811 9812 - issue91: introduce new py.test.xfail(reason) helper 9813 to imperatively mark a test as expected to fail. Can 9814 be used from within setup and test functions. This is 9815 useful especially for parametrized tests when certain 9816 configurations are expected-to-fail. In this case the 9817 declarative approach with the @py.test.mark.xfail cannot 9818 be used as it would mark all configurations as xfail. 9819 9820 - issue102: introduce new --maxfail=NUM option to stop 9821 test runs after NUM failures. This is a generalization 9822 of the '-x' or '--exitfirst' option which is now equivalent 9823 to '--maxfail=1'. Both '-x' and '--maxfail' will 9824 now also print a line near the end indicating the Interruption. 9825 9826 - issue89: allow py.test.mark decorators to be used on classes 9827 (class decorators were introduced with python2.6) and 9828 also allow to have multiple markers applied at class/module level 9829 by specifying a list. 9830 9831 - improve and refine letter reporting in the progress bar: 9832 . pass 9833 f failed test 9834 s skipped tests (reminder: use for dependency/platform mismatch only) 9835 x xfailed test (test that was expected to fail) 9836 X xpassed test (test that was expected to fail but passed) 9837 9838 You can use any combination of 'fsxX' with the '-r' extended 9839 reporting option. The xfail/xpass results will show up as 9840 skipped tests in the junitxml output - which also fixes 9841 issue99. 9842 9843 - make py.test.cmdline.main() return the exitstatus instead of raising 9844 SystemExit and also allow it to be called multiple times. This of 9845 course requires that your application and tests are properly teared 9846 down and don't have global state. 9847 9848 **Bug Fixes** 9849 9850 - improved traceback presentation: 9851 - improved and unified reporting for "--tb=short" option 9852 - Errors during test module imports are much shorter, (using --tb=short style) 9853 - raises shows shorter more relevant tracebacks 9854 - --fulltrace now more systematically makes traces longer / inhibits cutting 9855 9856 - improve support for raises and other dynamically compiled code by 9857 manipulating python's linecache.cache instead of the previous 9858 rather hacky way of creating custom code objects. This makes 9859 it seamlessly work on Jython and PyPy where it previously didn't. 9860 9861 - fix issue96: make capturing more resilient against Control-C 9862 interruptions (involved somewhat substantial refactoring 9863 to the underlying capturing functionality to avoid race 9864 conditions). 9865 9866 - fix chaining of conditional skipif/xfail decorators - so it works now 9867 as expected to use multiple @py.test.mark.skipif(condition) decorators, 9868 including specific reporting which of the conditions lead to skipping. 9869 9870 - fix issue95: late-import zlib so that it's not required 9871 for general py.test startup. 9872 9873 - fix issue94: make reporting more robust against bogus source code 9874 (and internally be more careful when presenting unexpected byte sequences) 9875 9876 9877 1.3.0 (2010-05-05) 9878 ================== 9879 9880 - deprecate --report option in favour of a new shorter and easier to 9881 remember -r option: it takes a string argument consisting of any 9882 combination of 'xfsX' characters. They relate to the single chars 9883 you see during the dotted progress printing and will print an extra line 9884 per test at the end of the test run. This extra line indicates the exact 9885 position or test ID that you directly paste to the py.test cmdline in order 9886 to re-run a particular test. 9887 9888 - allow external plugins to register new hooks via the new 9889 pytest_addhooks(pluginmanager) hook. The new release of 9890 the pytest-xdist plugin for distributed and looponfailing 9891 testing requires this feature. 9892 9893 - add a new pytest_ignore_collect(path, config) hook to allow projects and 9894 plugins to define exclusion behaviour for their directory structure - 9895 for example you may define in a conftest.py this method:: 9896 9897 def pytest_ignore_collect(path): 9898 return path.check(link=1) 9899 9900 to prevent even a collection try of any tests in symlinked dirs. 9901 9902 - new pytest_pycollect_makemodule(path, parent) hook for 9903 allowing customization of the Module collection object for a 9904 matching test module. 9905 9906 - extend and refine xfail mechanism: 9907 ``@py.test.mark.xfail(run=False)`` do not run the decorated test 9908 ``@py.test.mark.xfail(reason="...")`` prints the reason string in xfail summaries 9909 specifying ``--runxfail`` on command line virtually ignores xfail markers 9910 9911 - expose (previously internal) commonly useful methods: 9912 py.io.get_terminal_with() -> return terminal width 9913 py.io.ansi_print(...) -> print colored/bold text on linux/win32 9914 py.io.saferepr(obj) -> return limited representation string 9915 9916 - expose test outcome related exceptions as py.test.skip.Exception, 9917 py.test.raises.Exception etc., useful mostly for plugins 9918 doing special outcome interpretation/tweaking 9919 9920 - (issue85) fix junitxml plugin to handle tests with non-ascii output 9921 9922 - fix/refine python3 compatibility (thanks Benjamin Peterson) 9923 9924 - fixes for making the jython/win32 combination work, note however: 9925 jython2.5.1/win32 does not provide a command line launcher, see 9926 https://bugs.jython.org/issue1491 . See pylib install documentation 9927 for how to work around. 9928 9929 - fixes for handling of unicode exception values and unprintable objects 9930 9931 - (issue87) fix unboundlocal error in assertionold code 9932 9933 - (issue86) improve documentation for looponfailing 9934 9935 - refine IO capturing: stdin-redirect pseudo-file now has a NOP close() method 9936 9937 - ship distribute_setup.py version 0.6.10 9938 9939 - added links to the new capturelog and coverage plugins 9940 9941 9942 1.2.0 (2010-01-18) 9943 ================== 9944 9945 - refined usage and options for "py.cleanup":: 9946 9947 py.cleanup # remove "*.pyc" and "*$py.class" (jython) files 9948 py.cleanup -e .swp -e .cache # also remove files with these extensions 9949 py.cleanup -s # remove "build" and "dist" directory next to setup.py files 9950 py.cleanup -d # also remove empty directories 9951 py.cleanup -a # synonym for "-s -d -e 'pip-log.txt'" 9952 py.cleanup -n # dry run, only show what would be removed 9953 9954 - add a new option "py.test --funcargs" which shows available funcargs 9955 and their help strings (docstrings on their respective factory function) 9956 for a given test path 9957 9958 - display a short and concise traceback if a funcarg lookup fails 9959 9960 - early-load "conftest.py" files in non-dot first-level sub directories. 9961 allows to conveniently keep and access test-related options in a ``test`` 9962 subdir and still add command line options. 9963 9964 - 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 9965 9966 - fix issue78: always call python-level teardown functions even if the 9967 according setup failed. This includes refinements for calling setup_module/class functions 9968 which will now only be called once instead of the previous behaviour where they'd be called 9969 multiple times if they raise an exception (including a Skipped exception). Any exception 9970 will be re-corded and associated with all tests in the according module/class scope. 9971 9972 - fix issue63: assume <40 columns to be a bogus terminal width, default to 80 9973 9974 - fix pdb debugging to be in the correct frame on raises-related errors 9975 9976 - update apipkg.py to fix an issue where recursive imports might 9977 unnecessarily break importing 9978 9979 - fix plugin links 9980 9981 1.1.1 (2009-11-24) 9982 ================== 9983 9984 - moved dist/looponfailing from py.test core into a new 9985 separately released pytest-xdist plugin. 9986 9987 - new junitxml plugin: --junitxml=path will generate a junit style xml file 9988 which is processable e.g. by the Hudson CI system. 9989 9990 - new option: --genscript=path will generate a standalone py.test script 9991 which will not need any libraries installed. thanks to Ralf Schmitt. 9992 9993 - new option: --ignore will prevent specified path from collection. 9994 Can be specified multiple times. 9995 9996 - new option: --confcutdir=dir will make py.test only consider conftest 9997 files that are relative to the specified dir. 9998 9999 - new funcarg: "pytestconfig" is the pytest config object for access 10000 to command line args and can now be easily used in a test. 10001 10002 - install ``py.test`` and ``py.which`` with a ``-$VERSION`` suffix to 10003 disambiguate between Python3, python2.X, Jython and PyPy installed versions. 10004 10005 - new "pytestconfig" funcarg allows access to test config object 10006 10007 - new "pytest_report_header" hook can return additional lines 10008 to be displayed at the header of a test run. 10009 10010 - (experimental) allow "py.test path::name1::name2::..." for pointing 10011 to a test within a test collection directly. This might eventually 10012 evolve as a full substitute to "-k" specifications. 10013 10014 - streamlined plugin loading: order is now as documented in 10015 customize.html: setuptools, ENV, commandline, conftest. 10016 also setuptools entry point names are turned to canonical names ("pytest_*") 10017 10018 - automatically skip tests that need 'capfd' but have no os.dup 10019 10020 - allow pytest_generate_tests to be defined in classes as well 10021 10022 - deprecate usage of 'disabled' attribute in favour of pytestmark 10023 - deprecate definition of Directory, Module, Class and Function nodes 10024 in conftest.py files. Use pytest collect hooks instead. 10025 10026 - collection/item node specific runtest/collect hooks are only called exactly 10027 on matching conftest.py files, i.e. ones which are exactly below 10028 the filesystem path of an item 10029 10030 - change: the first pytest_collect_directory hook to return something 10031 will now prevent further hooks to be called. 10032 10033 - change: figleaf plugin now requires --figleaf to run. Also 10034 change its long command line options to be a bit shorter (see py.test -h). 10035 10036 - change: pytest doctest plugin is now enabled by default and has a 10037 new option --doctest-glob to set a pattern for file matches. 10038 10039 - change: remove internal py._* helper vars, only keep py._pydir 10040 10041 - robustify capturing to survive if custom pytest_runtest_setup 10042 code failed and prevented the capturing setup code from running. 10043 10044 - make py.test.* helpers provided by default plugins visible early - 10045 works transparently both for pydoc and for interactive sessions 10046 which will regularly see e.g. py.test.mark and py.test.importorskip. 10047 10048 - simplify internal plugin manager machinery 10049 - simplify internal collection tree by introducing a RootCollector node 10050 10051 - fix assert reinterpreation that sees a call containing "keyword=..." 10052 10053 - fix issue66: invoke pytest_sessionstart and pytest_sessionfinish 10054 hooks on worker nodes during dist-testing, report module/session teardown 10055 hooks correctly. 10056 10057 - fix issue65: properly handle dist-testing if no 10058 execnet/py lib installed remotely. 10059 10060 - skip some install-tests if no execnet is available 10061 10062 - fix docs, fix internal bin/ script generation 10063 10064 10065 1.1.0 (2009-11-05) 10066 ================== 10067 10068 - introduce automatic plugin registration via 'pytest11' 10069 entrypoints via setuptools' pkg_resources.iter_entry_points 10070 10071 - fix py.test dist-testing to work with execnet >= 1.0.0b4 10072 10073 - re-introduce py.test.cmdline.main() for better backward compatibility 10074 10075 - svn paths: fix a bug with path.check(versioned=True) for svn paths, 10076 allow '%' in svn paths, make svnwc.update() default to interactive mode 10077 like in 1.0.x and add svnwc.update(interactive=False) to inhibit interaction. 10078 10079 - refine distributed tarball to contain test and no pyc files 10080 10081 - try harder to have deprecation warnings for py.compat.* accesses 10082 report a correct location 10083 10084 1.0.3 10085 ===== 10086 10087 * adjust and improve docs 10088 10089 * remove py.rest tool and internal namespace - it was 10090 never really advertised and can still be used with 10091 the old release if needed. If there is interest 10092 it could be revived into its own tool i guess. 10093 10094 * fix issue48 and issue59: raise an Error if the module 10095 from an imported test file does not seem to come from 10096 the filepath - avoids "same-name" confusion that has 10097 been reported repeatedly 10098 10099 * merged Ronny's nose-compatibility hacks: now 10100 nose-style setup_module() and setup() functions are 10101 supported 10102 10103 * introduce generalized py.test.mark function marking 10104 10105 * reshuffle / refine command line grouping 10106 10107 * deprecate parser.addgroup in favour of getgroup which creates option group 10108 10109 * add --report command line option that allows to control showing of skipped/xfailed sections 10110 10111 * generalized skipping: a new way to mark python functions with skipif or xfail 10112 at function, class and modules level based on platform or sys-module attributes. 10113 10114 * extend py.test.mark decorator to allow for positional args 10115 10116 * introduce and test "py.cleanup -d" to remove empty directories 10117 10118 * fix issue #59 - robustify unittest test collection 10119 10120 * make bpython/help interaction work by adding an __all__ attribute 10121 to ApiModule, cleanup initpkg 10122 10123 * use MIT license for pylib, add some contributors 10124 10125 * remove py.execnet code and substitute all usages with 'execnet' proper 10126 10127 * fix issue50 - cached_setup now caches more to expectations 10128 for test functions with multiple arguments. 10129 10130 * merge Jarko's fixes, issue #45 and #46 10131 10132 * add the ability to specify a path for py.lookup to search in 10133 10134 * fix a funcarg cached_setup bug probably only occurring 10135 in distributed testing and "module" scope with teardown. 10136 10137 * many fixes and changes for making the code base python3 compatible, 10138 many thanks to Benjamin Peterson for helping with this. 10139 10140 * consolidate builtins implementation to be compatible with >=2.3, 10141 add helpers to ease keeping 2 and 3k compatible code 10142 10143 * deprecate py.compat.doctest|subprocess|textwrap|optparse 10144 10145 * deprecate py.magic.autopath, remove py/magic directory 10146 10147 * move pytest assertion handling to py/code and a pytest_assertion 10148 plugin, add "--no-assert" option, deprecate py.magic namespaces 10149 in favour of (less) py.code ones. 10150 10151 * consolidate and cleanup py/code classes and files 10152 10153 * cleanup py/misc, move tests to bin-for-dist 10154 10155 * introduce delattr/delitem/delenv methods to py.test's monkeypatch funcarg 10156 10157 * consolidate py.log implementation, remove old approach. 10158 10159 * introduce py.io.TextIO and py.io.BytesIO for distinguishing between 10160 text/unicode and byte-streams (uses underlying standard lib io.* 10161 if available) 10162 10163 * make py.unittest_convert helper script available which converts "unittest.py" 10164 style files into the simpler assert/direct-test-classes py.test/nosetests 10165 style. The script was written by Laura Creighton. 10166 10167 * simplified internal localpath implementation 10168 10169 1.0.2 (2009-08-27) 10170 ================== 10171 10172 * fixing packaging issues, triggered by fedora redhat packaging, 10173 also added doc, examples and contrib dirs to the tarball. 10174 10175 * added a documentation link to the new django plugin. 10176 10177 1.0.1 (2009-08-19) 10178 ================== 10179 10180 * added a 'pytest_nose' plugin which handles nose.SkipTest, 10181 nose-style function/method/generator setup/teardown and 10182 tries to report functions correctly. 10183 10184 * capturing of unicode writes or encoded strings to sys.stdout/err 10185 work better, also terminalwriting was adapted and somewhat 10186 unified between windows and linux. 10187 10188 * improved documentation layout and content a lot 10189 10190 * added a "--help-config" option to show conftest.py / ENV-var names for 10191 all longopt cmdline options, and some special conftest.py variables. 10192 renamed 'conf_capture' conftest setting to 'option_capture' accordingly. 10193 10194 * fix issue #27: better reporting on non-collectable items given on commandline 10195 (e.g. pyc files) 10196 10197 * fix issue #33: added --version flag (thanks Benjamin Peterson) 10198 10199 * fix issue #32: adding support for "incomplete" paths to wcpath.status() 10200 10201 * "Test" prefixed classes are *not* collected by default anymore if they 10202 have an __init__ method 10203 10204 * monkeypatch setenv() now accepts a "prepend" parameter 10205 10206 * improved reporting of collection error tracebacks 10207 10208 * simplified multicall mechanism and plugin architecture, 10209 renamed some internal methods and argnames 10210 10211 1.0.0 (2009-08-04) 10212 ================== 10213 10214 * more terse reporting try to show filesystem path relatively to current dir 10215 * improve xfail output a bit 10216 10217 1.0.0b9 (2009-07-31) 10218 ==================== 10219 10220 * cleanly handle and report final teardown of test setup 10221 10222 * fix svn-1.6 compat issue with py.path.svnwc().versioned() 10223 (thanks Wouter Vanden Hove) 10224 10225 * setup/teardown or collection problems now show as ERRORs 10226 or with big "E"'s in the progress lines. they are reported 10227 and counted separately. 10228 10229 * dist-testing: properly handle test items that get locally 10230 collected but cannot be collected on the remote side - often 10231 due to platform/dependency reasons 10232 10233 * simplified py.test.mark API - see keyword plugin documentation 10234 10235 * integrate better with logging: capturing now by default captures 10236 test functions and their immediate setup/teardown in a single stream 10237 10238 * capsys and capfd funcargs now have a readouterr() and a close() method 10239 (underlyingly py.io.StdCapture/FD objects are used which grew a 10240 readouterr() method as well to return snapshots of captured out/err) 10241 10242 * make assert-reinterpretation work better with comparisons not 10243 returning bools (reported with numpy from thanks maciej fijalkowski) 10244 10245 * reworked per-test output capturing into the pytest_iocapture.py plugin 10246 and thus removed capturing code from config object 10247 10248 * item.repr_failure(excinfo) instead of item.repr_failure(excinfo, outerr) 10249 10250 10251 1.0.0b8 (2009-07-22) 10252 ==================== 10253 10254 * pytest_unittest-plugin is now enabled by default 10255 10256 * introduced pytest_keyboardinterrupt hook and 10257 refined pytest_sessionfinish hooked, added tests. 10258 10259 * workaround a buggy logging module interaction ("closing already closed 10260 files"). Thanks to Sridhar Ratnakumar for triggering. 10261 10262 * if plugins use "py.test.importorskip" for importing 10263 a dependency only a warning will be issued instead 10264 of exiting the testing process. 10265 10266 * many improvements to docs: 10267 - refined funcargs doc , use the term "factory" instead of "provider" 10268 - added a new talk/tutorial doc page 10269 - better download page 10270 - better plugin docstrings 10271 - added new plugins page and automatic doc generation script 10272 10273 * fixed teardown problem related to partially failing funcarg setups 10274 (thanks MrTopf for reporting), "pytest_runtest_teardown" is now 10275 always invoked even if the "pytest_runtest_setup" failed. 10276 10277 * tweaked doctest output for docstrings in py modules, 10278 thanks Radomir. 10279 10280 1.0.0b7 10281 ======= 10282 10283 * renamed py.test.xfail back to py.test.mark.xfail to avoid 10284 two ways to decorate for xfail 10285 10286 * re-added py.test.mark decorator for setting keywords on functions 10287 (it was actually documented so removing it was not nice) 10288 10289 * remove scope-argument from request.addfinalizer() because 10290 request.cached_setup has the scope arg. TOOWTDI. 10291 10292 * perform setup finalization before reporting failures 10293 10294 * apply modified patches from Andreas Kloeckner to allow 10295 test functions to have no func_code (#22) and to make 10296 "-k" and function keywords work (#20) 10297 10298 * apply patch from Daniel Peolzleithner (issue #23) 10299 10300 * resolve issue #18, multiprocessing.Manager() and 10301 redirection clash 10302 10303 * make __name__ == "__channelexec__" for remote_exec code 10304 10305 1.0.0b3 (2009-06-19) 10306 ==================== 10307 10308 * plugin classes are removed: one now defines 10309 hooks directly in conftest.py or global pytest_*.py 10310 files. 10311 10312 * added new pytest_namespace(config) hook that allows 10313 to inject helpers directly to the py.test.* namespace. 10314 10315 * documented and refined many hooks 10316 10317 * added new style of generative tests via 10318 pytest_generate_tests hook that integrates 10319 well with function arguments. 10320 10321 10322 1.0.0b1 10323 ======= 10324 10325 * introduced new "funcarg" setup method, 10326 see doc/test/funcarg.txt 10327 10328 * introduced plugin architecture and many 10329 new py.test plugins, see 10330 doc/test/plugins.txt 10331 10332 * teardown_method is now guaranteed to get 10333 called after a test method has run. 10334 10335 * new method: py.test.importorskip(mod,minversion) 10336 will either import or call py.test.skip() 10337 10338 * completely revised internal py.test architecture 10339 10340 * new py.process.ForkedFunc object allowing to 10341 fork execution of a function to a sub process 10342 and getting a result back. 10343 10344 XXX lots of things missing here XXX 10345 10346 0.9.2 10347 ===== 10348 10349 * refined installation and metadata, created new setup.py, 10350 now based on setuptools/ez_setup (thanks to Ralf Schmitt 10351 for his support). 10352 10353 * improved the way of making py.* scripts available in 10354 windows environments, they are now added to the 10355 Scripts directory as ".cmd" files. 10356 10357 * py.path.svnwc.status() now is more complete and 10358 uses xml output from the 'svn' command if available 10359 (Guido Wesdorp) 10360 10361 * fix for py.path.svn* to work with svn 1.5 10362 (Chris Lamb) 10363 10364 * fix path.relto(otherpath) method on windows to 10365 use normcase for checking if a path is relative. 10366 10367 * py.test's traceback is better parseable from editors 10368 (follows the filenames:LINENO: MSG convention) 10369 (thanks to Osmo Salomaa) 10370 10371 * fix to javascript-generation, "py.test --runbrowser" 10372 should work more reliably now 10373 10374 * removed previously accidentally added 10375 py.test.broken and py.test.notimplemented helpers. 10376 10377 * there now is a py.__version__ attribute 10378 10379 0.9.1 10380 ===== 10381 10382 This is a fairly complete list of v0.9.1, which can 10383 serve as a reference for developers. 10384 10385 * allowing + signs in py.path.svn urls [39106] 10386 * fixed support for Failed exceptions without excinfo in py.test [39340] 10387 * added support for killing processes for Windows (as well as platforms that 10388 support os.kill) in py.misc.killproc [39655] 10389 * added setup/teardown for generative tests to py.test [40702] 10390 * added detection of FAILED TO LOAD MODULE to py.test [40703, 40738, 40739] 10391 * fixed problem with calling .remove() on wcpaths of non-versioned files in 10392 py.path [44248] 10393 * fixed some import and inheritance issues in py.test [41480, 44648, 44655] 10394 * fail to run greenlet tests when pypy is available, but without stackless 10395 [45294] 10396 * small fixes in rsession tests [45295] 10397 * fixed issue with 2.5 type representations in py.test [45483, 45484] 10398 * made that internal reporting issues displaying is done atomically in py.test 10399 [45518] 10400 * made that non-existing files are ignored by the py.lookup script [45519] 10401 * improved exception name creation in py.test [45535] 10402 * made that less threads are used in execnet [merge in 45539] 10403 * removed lock required for atomic reporting issue displaying in py.test 10404 [45545] 10405 * removed globals from execnet [45541, 45547] 10406 * refactored cleanup mechanics, made that setDaemon is set to 1 to make atexit 10407 get called in 2.5 (py.execnet) [45548] 10408 * fixed bug in joining threads in py.execnet's servemain [45549] 10409 * refactored py.test.rsession tests to not rely on exact output format anymore 10410 [45646] 10411 * using repr() on test outcome [45647] 10412 * added 'Reason' classes for py.test.skip() [45648, 45649] 10413 * killed some unnecessary sanity check in py.test.collect [45655] 10414 * avoid using os.tmpfile() in py.io.fdcapture because on Windows it's only 10415 usable by Administrators [45901] 10416 * added support for locking and non-recursive commits to py.path.svnwc [45994] 10417 * locking files in py.execnet to prevent CPython from segfaulting [46010] 10418 * added export() method to py.path.svnurl 10419 * fixed -d -x in py.test [47277] 10420 * fixed argument concatenation problem in py.path.svnwc [49423] 10421 * restore py.test behaviour that it exits with code 1 when there are failures 10422 [49974] 10423 * don't fail on html files that don't have an accompanying .txt file [50606] 10424 * fixed 'utestconvert.py < input' [50645] 10425 * small fix for code indentation in py.code.source [50755] 10426 * fix _docgen.py documentation building [51285] 10427 * improved checks for source representation of code blocks in py.test [51292] 10428 * added support for passing authentication to py.path.svn* objects [52000, 10429 52001] 10430 * removed sorted() call for py.apigen tests in favour of [].sort() to support 10431 Python 2.3 [52481]