Pytest

Latest version: v8.2.0

Safety actively analyzes 630305 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 16 of 33

3.9.1

=========================

Features
--------

- :issue:`4159`: For test-suites containing test classes, the information about the subclassed
module is now output only if a higher verbosity level is specified (at least
"-vv").

3.9.0

=========================================================================

Deprecations
------------

- :issue:`3616`: The following accesses have been documented as deprecated for years, but are now actually emitting deprecation warnings.

* Access of ``Module``, ``Function``, ``Class``, ``Instance``, ``File`` and ``Item`` through ``Node`` instances. Now
users will this warning::

usage of Function.Module is deprecated, please use pytest.Module instead

Users should just ``import pytest`` and access those objects using the ``pytest`` module.

* ``request.cached_setup``, this was the precursor of the setup/teardown mechanism available to fixtures. You can
consult :std:doc:`funcarg comparison section in the docs <funcarg_compare>`.

* Using objects named ``"Class"`` as a way to customize the type of nodes that are collected in ``Collector``
subclasses has been deprecated. Users instead should use ``pytest_collect_make_item`` to customize node types during
collection.

This issue should affect only advanced plugins who create new collection types, so if you see this warning
message please contact the authors so they can change the code.

* The warning that produces the message below has changed to ``RemovedInPytest4Warning``::

getfuncargvalue is deprecated, use getfixturevalue


- :issue:`3988`: Add a Deprecation warning for pytest.ensuretemp as it was deprecated since a while.



Features
--------

- :issue:`2293`: Improve usage errors messages by hiding internal details which can be distracting and noisy.

This has the side effect that some error conditions that previously raised generic errors (such as
``ValueError`` for unregistered marks) are now raising ``Failed`` exceptions.


- :issue:`3332`: Improve the error displayed when a ``conftest.py`` file could not be imported.

In order to implement this, a new ``chain`` parameter was added to ``ExceptionInfo.getrepr``
to show or hide chained tracebacks in Python 3 (defaults to ``True``).


- :issue:`3849`: Add ``empty_parameter_set_mark=fail_at_collect`` ini option for raising an exception when parametrize collects an empty set.


- :issue:`3964`: Log messages generated in the collection phase are shown when
live-logging is enabled and/or when they are logged to a file.


- :issue:`3985`: Introduce ``tmp_path`` as a fixture providing a Path object. Also introduce ``tmp_path_factory`` as
a session-scoped fixture for creating arbitrary temporary directories from any other fixture or test.


- :issue:`4013`: Deprecation warnings are now shown even if you customize the warnings filters yourself. In the previous version
any customization would override pytest's filters and deprecation warnings would fall back to being hidden by default.


- :issue:`4073`: Allow specification of timeout for ``Testdir.runpytest_subprocess()`` and ``Testdir.run()``.


- :issue:`4098`: Add returncode argument to pytest.exit() to exit pytest with a specific return code.


- :issue:`4102`: Reimplement ``pytest.deprecated_call`` using ``pytest.warns`` so it supports the ``match='...'`` keyword argument.

This has the side effect that ``pytest.deprecated_call`` now raises ``pytest.fail.Exception`` instead
of ``AssertionError``.


- :issue:`4149`: Require setuptools>=30.3 and move most of the metadata to ``setup.cfg``.



Bug Fixes
---------

- :issue:`2535`: Improve error message when test functions of ``unittest.TestCase`` subclasses use a parametrized fixture.


- :issue:`3057`: ``request.fixturenames`` now correctly returns the name of fixtures created by ``request.getfixturevalue()``.


- :issue:`3946`: Warning filters passed as command line options using ``-W`` now take precedence over filters defined in ``ini``
configuration files.


- :issue:`4066`: Fix source reindenting by using ``textwrap.dedent`` directly.


- :issue:`4102`: ``pytest.warn`` will capture previously-warned warnings in Python 2. Previously they were never raised.


- :issue:`4108`: Resolve symbolic links for args.

This fixes running ``pytest tests/test_foo.py::test_bar``, where ``tests``
is a symlink to ``project/app/tests``:
previously ``project/app/conftest.py`` would be ignored for fixtures then.


- :issue:`4132`: Fix duplicate printing of internal errors when using ``--pdb``.


- :issue:`4135`: pathlib based tmpdir cleanup now correctly handles symlinks in the folder.


- :issue:`4152`: Display the filename when encountering ``SyntaxWarning``.



Improved Documentation
----------------------

- :issue:`3713`: Update usefixtures documentation to clarify that it can't be used with fixture functions.


- :issue:`4058`: Update fixture documentation to specify that a fixture can be invoked twice in the scope it's defined for.


- :issue:`4064`: According to unittest.rst, setUpModule and tearDownModule were not implemented, but it turns out they are. So updated the documentation for unittest.


- :issue:`4151`: Add tempir testing example to CONTRIBUTING.rst guide



Trivial/Internal Changes
------------------------

- :issue:`2293`: The internal ``MarkerError`` exception has been removed.


- :issue:`3988`: Port the implementation of tmpdir to pathlib.


- :issue:`4063`: Exclude 0.00 second entries from ``--duration`` output unless ``-vv`` is passed on the command-line.


- :issue:`4093`: Fixed formatting of string literals in internal tests.

3.8.2

=========================

Deprecations and Removals
-------------------------

- :issue:`4036`: The ``item`` parameter of ``pytest_warning_captured`` hook is now documented as deprecated. We realized only after
the ``3.8`` release that this parameter is incompatible with ``pytest-xdist``.

Our policy is to not deprecate features during bug-fix releases, but in this case we believe it makes sense as we are
only documenting it as deprecated, without issuing warnings which might potentially break test suites. This will get
the word out that hook implementers should not use this parameter at all.

In a future release ``item`` will always be ``None`` and will emit a proper warning when a hook implementation
makes use of it.



Bug Fixes
---------

- :issue:`3539`: Fix reload on assertion rewritten modules.


- :issue:`4034`: The ``.user_properties`` attribute of ``TestReport`` objects is a list
of (name, value) tuples, but could sometimes be instantiated as a tuple
of tuples. It is now always a list.


- :issue:`4039`: No longer issue warnings about using ``pytest_plugins`` in non-top-level directories when using ``--pyargs``: the
current ``--pyargs`` mechanism is not reliable and might give false negatives.


- :issue:`4040`: Exclude empty reports for passed tests when ``-rP`` option is used.


- :issue:`4051`: Improve error message when an invalid Python expression is passed to the ``-m`` option.


- :issue:`4056`: ``MonkeyPatch.setenv`` and ``MonkeyPatch.delenv`` issue a warning if the environment variable name is not ``str`` on Python 2.

In Python 2, adding ``unicode`` keys to ``os.environ`` causes problems with ``subprocess`` (and possible other modules),
making this a subtle bug specially susceptible when used with ``from __future__ import unicode_literals``.



Improved Documentation
----------------------

- :issue:`3928`: Add possible values for fixture scope to docs.

3.8.1

=========================

Bug Fixes
---------

- :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.


- :issue:`3749`: Fix the following error during collection of tests inside packages::

TypeError: object of type 'Package' has no len()


- :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.


- :issue:`3973`: Fix crash of the assertion rewriter if a test changed the current working directory without restoring it afterwards.


- :issue:`3998`: Fix issue that prevented some caplog properties (for example ``record_tuples``) from being available when entering the debugger with ``--pdb``.


- :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.



Improved Documentation
----------------------

- :issue:`3996`: New :std:doc:`deprecations` page shows all currently
deprecated features, the rationale to do so, and alternatives to update your code. It also list features removed
from pytest in past major releases to help those with ancient pytest versions to upgrade.



Trivial/Internal Changes
------------------------

- :issue:`3955`: Improve pre-commit detection for changelog filenames


- :issue:`3975`: Remove legacy code around im_func as that was python2 only

3.8.0

=========================

Deprecations and Removals
-------------------------

- :issue:`2452`: ``Config.warn`` and ``Node.warn`` have been
deprecated, see :ref:`config.warn and node.warn deprecated` for rationale and
examples.

- :issue:`3936`: ``pytest.mark.filterwarnings`` second parameter is no longer regex-escaped,
making it possible to actually use regular expressions to check the warning message.

**Note**: regex-escaping the match string was an implementation oversight that might break test suites which depend
on the old behavior.



Features
--------

- :issue:`2452`: Internal pytest warnings are now issued using the standard ``warnings`` module, making it possible to use
the standard warnings filters to manage those warnings. This introduces ``PytestWarning``,
``PytestDeprecationWarning`` and ``RemovedInPytest4Warning`` warning types as part of the public API.

Consult :ref:`the documentation <internal-warnings>` for more info.


- :issue:`2908`: ``DeprecationWarning`` and ``PendingDeprecationWarning`` are now shown by default if no other warning filter is
configured. This makes pytest more compliant with
:pep:`506recommended-filter-settings-for-test-runners`. See
:ref:`the docs <deprecation-warnings>` for
more info.


- :issue:`3251`: Warnings are now captured and displayed during test collection.


- :issue:`3784`: ``PYTEST_DISABLE_PLUGIN_AUTOLOAD`` environment variable disables plugin auto-loading when set.


- :issue:`3829`: Added the ``count`` option to ``console_output_style`` to enable displaying the progress as a count instead of a percentage.


- :issue:`3837`: Added support for 'xfailed' and 'xpassed' outcomes to the ``pytester.RunResult.assert_outcomes`` signature.



Bug Fixes
---------

- :issue:`3911`: Terminal writer now takes into account unicode character width when writing out progress.


- :issue:`3913`: Pytest now returns with correct exit code (EXIT_USAGEERROR, 4) when called with unknown arguments.


- :issue:`3918`: Improve performance of assertion rewriting.



Improved Documentation
----------------------

- :issue:`3566`: Added a blurb in usage.rst for the usage of -r flag which is used to show an extra test summary info.


- :issue:`3907`: Corrected type of the exceptions collection passed to ``xfail``: ``raises`` argument accepts a ``tuple`` instead of ``list``.



Trivial/Internal Changes
------------------------

- :issue:`3853`: Removed ``"run all (no recorded failures)"`` message printed with ``--failed-first`` and ``--last-failed`` when there are no failed tests.

3.7.4

=========================

Bug Fixes
---------

- :issue:`3506`: Fix possible infinite recursion when writing ``.pyc`` files.


- :issue:`3853`: Cache plugin now obeys the ``-q`` flag when ``--last-failed`` and ``--failed-first`` flags are used.


- :issue:`3883`: Fix bad console output when using ``console_output_style=classic``.


- :issue:`3888`: Fix macOS specific code using ``capturemanager`` plugin in doctests.



Improved Documentation
----------------------

- :issue:`3902`: Fix pytest.org links

Page 16 of 33

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.