Pytest

Latest version: v8.2.0

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

Scan your dependencies

Page 21 of 33

3.1.2

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

Bug Fixes
---------

- Required options added via ``pytest_addoption`` will no longer prevent using
--help without passing them. (1999)

- Respect ``python_files`` in assertion rewriting. (2121)

- Fix recursion error detection when frames in the traceback contain objects
that can't be compared (like ``numpy`` arrays). (2459)

- ``UnicodeWarning`` is issued from the internal pytest warnings plugin only
when the message contains non-ascii unicode (Python 2 only). (2463)

- Added a workaround for Python 3.6 ``WindowsConsoleIO`` breaking due to Pytests's
``FDCapture``. Other code using console handles might still be affected by the
very same issue and might require further workarounds/fixes, i.e. ``colorama``.
(2467)


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

- Fix internal API links to ``pluggy`` objects. (2331)

- Make it clear that ``pytest.xfail`` stops test execution at the calling point
and improve overall flow of the ``skipping`` docs. (810)

3.1.1

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

Bug Fixes
---------

- pytest warning capture no longer overrides existing warning filters. The
previous behaviour would override all filters and caused regressions in test
suites which configure warning filters to match their needs. Note that as a
side-effect of this is that ``DeprecationWarning`` and
``PendingDeprecationWarning`` are no longer shown by default. (2430)

- Fix issue with non-ascii contents in doctest text files. (2434)

- Fix encoding errors for unicode warnings in Python 2. (2436)

- ``pytest.deprecated_call`` now captures ``PendingDeprecationWarning`` in
context manager form. (2441)


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

- Addition of towncrier for changelog management. (2390)

3.1.0

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


New Features
------------

* The ``pytest-warnings`` plugin has been integrated into the core and now ``pytest`` automatically
captures and displays warnings at the end of the test session.

.. warning::

This feature may disrupt test suites which apply and treat warnings themselves, and can be
disabled in your ``pytest.ini``:

.. code-block:: ini

[pytest]
addopts = -p no:warnings

See the :doc:`warnings documentation page <how-to/capture-warnings>` for more
information.

Thanks :user:`nicoddemus` for the PR.

* Added ``junit_suite_name`` ini option to specify root ``<testsuite>`` name for JUnit XML reports (:issue:`533`).

* Added an ini option ``doctest_encoding`` to specify which encoding to use for doctest files.
Thanks :user:`wheerd` for the PR (:pull:`2101`).

* ``pytest.warns`` now checks for subclass relationship rather than
class equality. Thanks :user:`lesteve` for the PR (:pull:`2166`)

* ``pytest.raises`` now asserts that the error message matches a text or regex
with the ``match`` keyword argument. Thanks :user:`Kriechi` for the PR.

* ``pytest.param`` can be used to declare test parameter sets with marks and test ids.
Thanks :user:`RonnyPfannschmidt` for the PR.


Changes
-------

* remove all internal uses of pytest_namespace hooks,
this is to prepare the removal of preloadconfig in pytest 4.0
Thanks to :user:`RonnyPfannschmidt` for the PR.

* pytest now warns when a callable ids raises in a parametrized test. Thanks :user:`fogo` for the PR.

* It is now possible to skip test classes from being collected by setting a
``__test__`` attribute to ``False`` in the class body (:issue:`2007`). Thanks
to :user:`syre` for the report and :user:`lwm` for the PR.

* Change junitxml.py to produce reports that comply with Junitxml schema.
If the same test fails with failure in call and then errors in teardown
we split testcase element into two, one containing the error and the other
the failure. (:issue:`2228`) Thanks to :user:`kkoukiou` for the PR.

* Testcase reports with a ``url`` attribute will now properly write this to junitxml.
Thanks :user:`fushi` for the PR (:pull:`1874`).

* Remove common items from dict comparison output when verbosity=1. Also update
the truncation message to make it clearer that pytest truncates all
assertion messages if verbosity < 2 (:issue:`1512`).
Thanks :user:`mattduck` for the PR

* ``--pdbcls`` no longer implies ``--pdb``. This makes it possible to use
``addopts=--pdbcls=module.SomeClass`` on ``pytest.ini``. Thanks :user:`davidszotten` for
the PR (:pull:`1952`).

* fix :issue:`2013`: turn RecordedWarning into ``namedtuple``,
to give it a comprehensible repr while preventing unwarranted modification.

* fix :issue:`2208`: ensure an iteration limit for ``_pytest.compat.get_real_func``.
Thanks :user:`RonnyPfannschmidt` for the report and PR.

* Hooks are now verified after collection is complete, rather than right after loading installed plugins. This
makes it easy to write hooks for plugins which will be loaded during collection, for example using the
``pytest_plugins`` special variable (:issue:`1821`).
Thanks :user:`nicoddemus` for the PR.

* Modify ``pytest_make_parametrize_id()`` hook to accept ``argname`` as an
additional parameter.
Thanks :user:`unsignedint` for the PR.

* Add ``venv`` to the default ``norecursedirs`` setting.
Thanks :user:`The-Compiler` for the PR.

* ``PluginManager.import_plugin`` now accepts unicode plugin names in Python 2.
Thanks :user:`reutsharabani` for the PR.

* fix :issue:`2308`: When using both ``--lf`` and ``--ff``, only the last failed tests are run.
Thanks :user:`ojii` for the PR.

* Replace minor/patch level version numbers in the documentation with placeholders.
This significantly reduces change-noise as different contributors regenerate
the documentation on different platforms.
Thanks :user:`RonnyPfannschmidt` for the PR.

* fix :issue:`2391`: consider pytest_plugins on all plugin modules
Thanks :user:`RonnyPfannschmidt` for the PR.


Bug Fixes
---------

* Fix ``AttributeError`` on ``sys.stdout.buffer`` / ``sys.stderr.buffer``
while using ``capsys`` fixture in python 3. (:issue:`1407`).
Thanks to :user:`asottile`.

* Change capture.py's ``DontReadFromInput`` class to throw ``io.UnsupportedOperation`` errors rather
than ValueErrors in the ``fileno`` method (:issue:`2276`).
Thanks :user:`metasyn` and :user:`vlad-dragos` for the PR.

* Fix exception formatting while importing modules when the exception message
contains non-ascii characters (:issue:`2336`).
Thanks :user:`fabioz` for the report and :user:`nicoddemus` for the PR.

* Added documentation related to issue (:issue:`1937`)
Thanks :user:`skylarjhdownes` for the PR.

* Allow collecting files with any file extension as Python modules (:issue:`2369`).
Thanks :user:`Kodiologist` for the PR.

* Show the correct error message when collect "parametrize" func with wrong args (:issue:`2383`).
Thanks :user:`The-Compiler` for the report and :user:`robin0371` for the PR.

3.0.7

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


* Fix issue in assertion rewriting breaking due to modules silently discarding
other modules when importing fails
Notably, importing the ``anydbm`` module is fixed. (:issue:`2248`).
Thanks :user:`pfhayes` for the PR.

* junitxml: Fix problematic case where system-out tag occurred twice per testcase
element in the XML report. Thanks :user:`kkoukiou` for the PR.

* Fix regression, pytest now skips unittest correctly if run with ``--pdb``
(:issue:`2137`). Thanks to :user:`gst` for the report and :user:`mbyt` for the PR.

* Ignore exceptions raised from descriptors (e.g. properties) during Python test collection (:issue:`2234`).
Thanks to :user:`bluetech`.

* ``--override-ini`` now correctly overrides some fundamental options like ``python_files`` (:issue:`2238`).
Thanks :user:`sirex` for the report and :user:`nicoddemus` for the PR.

* Replace ``raise StopIteration`` usages in the code by simple ``returns`` to finish generators, in accordance to :pep:`479` (:issue:`2160`).
Thanks to :user:`nicoddemus` for the PR.

* Fix internal errors when an unprintable ``AssertionError`` is raised inside a test.
Thanks :user:`omerhadari` for the PR.

* Skipping plugin now also works with test items generated by custom collectors (:issue:`2231`).
Thanks to :user:`vidartf`.

* Fix trailing whitespace in console output if no .ini file presented (:issue:`2281`). Thanks :user:`fbjorn` for the PR.

* Conditionless ``xfail`` markers no longer rely on the underlying test item
being an instance of ``PyobjMixin``, and can therefore apply to tests not
collected by the built-in python test collector. Thanks :user:`barneygale` for the
PR.

3.0.6

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

* pytest no longer generates ``PendingDeprecationWarning`` from its own operations, which was introduced by mistake in version ``3.0.5`` (:issue:`2118`).
Thanks to :user:`nicoddemus` for the report and :user:`RonnyPfannschmidt` for the PR.


* pytest no longer recognizes coroutine functions as yield tests (:issue:`2129`).
Thanks to :user:`malinoff` for the PR.

* Plugins loaded by the ``PYTEST_PLUGINS`` environment variable are now automatically
considered for assertion rewriting (:issue:`2185`).
Thanks :user:`nicoddemus` for the PR.

* Improve error message when pytest.warns fails (:issue:`2150`). The type(s) of the
expected warnings and the list of caught warnings is added to the
error message. Thanks :user:`lesteve` for the PR.

* Fix ``pytester`` internal plugin to work correctly with latest versions of
``zope.interface`` (:issue:`1989`). Thanks :user:`nicoddemus` for the PR.

* Assert statements of the ``pytester`` plugin again benefit from assertion rewriting (:issue:`1920`).
Thanks :user:`RonnyPfannschmidt` for the report and :user:`nicoddemus` for the PR.

* Specifying tests with colons like ``test_foo.py::test_bar`` for tests in
subdirectories with ini configuration files now uses the correct ini file
(:issue:`2148`). Thanks :user:`pelme`.

* Fail ``testdir.runpytest().assert_outcomes()`` explicitly if the pytest
terminal output it relies on is missing. Thanks to :user:`eli-b` for the PR.

3.0.5

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

* Add warning when not passing ``option=value`` correctly to ``-o/--override-ini`` (:issue:`2105`).
Also improved the help documentation. Thanks to :user:`mbukatov` for the report and
:user:`lwm` for the PR.

* Now ``--confcutdir`` and ``--junit-xml`` are properly validated if they are directories
and filenames, respectively (:issue:`2089` and :issue:`2078`). Thanks to :user:`lwm` for the PR.

* Add hint to error message hinting possible missing ``__init__.py`` (:issue:`478`). Thanks :user:`DuncanBetts`.

* More accurately describe when fixture finalization occurs in documentation (:issue:`687`). Thanks :user:`DuncanBetts`.

* Provide ``:ref:`` targets for ``recwarn.rst`` so we can use intersphinx referencing.
Thanks to :user:`dupuy` for the report and :user:`lwm` for the PR.

* In Python 2, use a simple ``+-`` ASCII string in the string representation of ``pytest.approx`` (for example ``"4 +- 4.0e-06"``)
because it is brittle to handle that in different contexts and representations internally in pytest
which can result in bugs such as :issue:`2111`. In Python 3, the representation still uses ``±`` (for example ``4 ± 4.0e-06``).
Thanks :user:`kerrick-lyft` for the report and :user:`nicoddemus` for the PR.

* Using ``item.Function``, ``item.Module``, etc., is now issuing deprecation warnings, prefer
``pytest.Function``, ``pytest.Module``, etc., instead (:issue:`2034`).
Thanks :user:`nmundar` for the PR.

* Fix error message using ``approx`` with complex numbers (:issue:`2082`).
Thanks :user:`adler-j` for the report and :user:`nicoddemus` for the PR.

* Fixed false-positives warnings from assertion rewrite hook for modules imported more than
once by the ``pytest_plugins`` mechanism.
Thanks :user:`nicoddemus` for the PR.

* Remove an internal cache which could cause hooks from ``conftest.py`` files in
sub-directories to be called in other directories incorrectly (:issue:`2016`).
Thanks :user:`d-b-w` for the report and :user:`nicoddemus` for the PR.

* Remove internal code meant to support earlier Python 3 versions that produced the side effect
of leaving ``None`` in ``sys.modules`` when expressions were evaluated by pytest (for example passing a condition
as a string to ``pytest.mark.skipif``)(:issue:`2103`).
Thanks :user:`jaraco` for the report and :user:`nicoddemus` for the PR.

* Cope gracefully with a .pyc file with no matching .py file (:issue:`2038`). Thanks
:user:`nedbat`.

Page 21 of 33

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.