Pytest

Latest version: v8.2.0

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

Scan your dependencies

Page 19 of 33

3.4.1

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

Bug Fixes
---------

- Move import of ``doctest.UnexpectedException`` to top-level to avoid possible
errors when using ``--pdb``. (:issue:`1810`)

- Added printing of captured stdout/stderr before entering pdb, and improved a
test which was giving false negatives about output capturing. (:issue:`3052`)

- Fix ordering of tests using parametrized fixtures which can lead to fixtures
being created more than necessary. (:issue:`3161`)

- Fix bug where logging happening at hooks outside of "test run" hooks would
cause an internal error. (:issue:`3184`)

- Detect arguments injected by ``unittest.mock.patch`` decorator correctly when
pypi ``mock.patch`` is installed and imported. (:issue:`3206`)

- Errors shown when a ``pytest.raises()`` with ``match=`` fails are now cleaner
on what happened: When no exception was raised, the "matching '...'" part got
removed as it falsely implies that an exception was raised but it didn't
match. When a wrong exception was raised, it's now thrown (like
``pytest.raised()`` without ``match=`` would) instead of complaining about
the unmatched text. (:issue:`3222`)

- Fixed output capture handling in doctests on macOS. (:issue:`985`)


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

- Add Sphinx parameter docs for ``match`` and ``message`` args to
``pytest.raises``. (:issue:`3202`)


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

- pytest has changed the publication procedure and is now being published to
PyPI directly from Travis. (:issue:`3060`)

- Rename ``ParameterSet._for_parameterize()`` to ``_for_parametrize()`` in
order to comply with the naming convention. (:issue:`3166`)

- Skip failing pdb/doctest test on mac. (:issue:`985`)

3.4.0

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

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

- All pytest classes now subclass ``object`` for better Python 2/3 compatibility.
This should not affect user code except in very rare edge cases. (:issue:`2147`)


Features
--------

- Introduce ``empty_parameter_set_mark`` ini option to select which mark to
apply when ``pytest.mark.parametrize`` is given an empty set of parameters.
Valid options are ``skip`` (default) and ``xfail``. Note that it is planned
to change the default to ``xfail`` in future releases as this is considered
less error prone. (:issue:`2527`)

- **Incompatible change**: after community feedback the :doc:`logging <how-to/logging>` functionality has
undergone some changes. Please consult the :ref:`logging documentation <log_changes_3_4>`
for details. (:issue:`3013`)

- Console output falls back to "classic" mode when capturing is disabled (``-s``),
otherwise the output gets garbled to the point of being useless. (:issue:`3038`)

- New :hook:`pytest_runtest_logfinish`
hook which is called when a test item has finished executing, analogous to
:hook:`pytest_runtest_logstart`.
(:issue:`3101`)

- Improve performance when collecting tests using many fixtures. (:issue:`3107`)

- New ``caplog.get_records(when)`` method which provides access to the captured
records for the ``"setup"``, ``"call"`` and ``"teardown"``
testing stages. (:issue:`3117`)

- New fixture ``record_xml_attribute`` that allows modifying and inserting
attributes on the ``<testcase>`` xml node in JUnit reports. (:issue:`3130`)

- The default cache directory has been renamed from ``.cache`` to
``.pytest_cache`` after community feedback that the name ``.cache`` did not
make it clear that it was used by pytest. (:issue:`3138`)

- Colorize the levelname column in the live-log output. (:issue:`3142`)


Bug Fixes
---------

- Fix hanging pexpect test on MacOS by using flush() instead of wait().
(:issue:`2022`)

- Fix restoring Python state after in-process pytest runs with the
``pytester`` plugin; this may break tests using multiple inprocess
pytest runs if later ones depend on earlier ones leaking global interpreter
changes. (:issue:`3016`)

- Fix skipping plugin reporting hook when test aborted before plugin setup
hook. (:issue:`3074`)

- Fix progress percentage reported when tests fail during teardown. (:issue:`3088`)

- **Incompatible change**: ``-o/--override`` option no longer eats all the
remaining options, which can lead to surprising behavior: for example,
``pytest -o foo=1 /path/to/test.py`` would fail because ``/path/to/test.py``
would be considered as part of the ``-o`` command-line argument. One
consequence of this is that now multiple configuration overrides need
multiple ``-o`` flags: ``pytest -o foo=1 -o bar=2``. (:issue:`3103`)


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

- Document hooks (defined with ``historic=True``) which cannot be used with
``hookwrapper=True``. (:issue:`2423`)

- Clarify that warning capturing doesn't change the warning filter by default.
(:issue:`2457`)

- Clarify a possible confusion when using pytest_fixture_setup with fixture
functions that return None. (:issue:`2698`)

- Fix the wording of a sentence on doctest flags used in pytest. (:issue:`3076`)

- Prefer ``https://*.readthedocs.io`` over ``http://*.rtfd.org`` for links in
the documentation. (:issue:`3092`)

- Improve readability (wording, grammar) of Getting Started guide (:issue:`3131`)

- Added note that calling pytest.main multiple times from the same process is
not recommended because of import caching. (:issue:`3143`)


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

- Show a simple and easy error when keyword expressions trigger a syntax error
(for example, ``"-k foo and import"`` will show an error that you can not use
the ``import`` keyword in expressions). (:issue:`2953`)

- Change parametrized automatic test id generation to use the ``__name__``
attribute of functions instead of the fallback argument name plus counter.
(:issue:`2976`)

- Replace py.std with stdlib imports. (:issue:`3067`)

- Corrected 'you' to 'your' in logging docs. (:issue:`3129`)

3.3.2

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

Bug Fixes
---------

- pytester: ignore files used to obtain current user metadata in the fd leak
detector. (:issue:`2784`)

- Fix **memory leak** where objects returned by fixtures were never destructed
by the garbage collector. (:issue:`2981`)

- Fix conversion of pyargs to filename to not convert symlinks on Python 2. (:issue:`2985`)

- ``PYTEST_DONT_REWRITE`` is now checked for plugins too rather than only for
test modules. (:issue:`2995`)


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

- Add clarifying note about behavior of multiple parametrized arguments (:issue:`3001`)


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

- Code cleanup. (:issue:`3015`,
:issue:`3021`)

- Clean up code by replacing imports and references of ``_ast`` to ``ast``.
(:issue:`3018`)

3.3.1

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

Bug Fixes
---------

- Fix issue about ``-p no:<plugin>`` having no effect. (:issue:`2920`)

- Fix regression with warnings that contained non-strings in their arguments in
Python 2. (:issue:`2956`)

- Always escape null bytes when setting ``PYTEST_CURRENT_TEST``. (:issue:`2957`)

- Fix ``ZeroDivisionError`` when using the ``testmon`` plugin when no tests
were actually collected. (:issue:`2971`)

- Bring back ``TerminalReporter.writer`` as an alias to
``TerminalReporter._tw``. This alias was removed by accident in the ``3.3.0``
release. (:issue:`2984`)

- The ``pytest-capturelog`` plugin is now also blacklisted, avoiding errors when
running pytest with it still installed. (:issue:`3004`)


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

- Fix broken link to plugin ``pytest-localserver``. (:issue:`2963`)


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

- Update github "bugs" link in ``CONTRIBUTING.rst`` (:issue:`2949`)

3.3.0

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

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

- pytest no longer supports Python **2.6** and **3.3**. Those Python versions
are EOL for some time now and incur maintenance and compatibility costs on
the pytest core team, and following up with the rest of the community we
decided that they will no longer be supported starting on this version. Users
which still require those versions should pin pytest to ``<3.3``. (:issue:`2812`)

- Remove internal ``_preloadplugins()`` function. This removal is part of the
``pytest_namespace()`` hook deprecation. (:issue:`2636`)

- Internally change ``CallSpec2`` to have a list of marks instead of a broken
mapping of keywords. This removes the keywords attribute of the internal
``CallSpec2`` class. (:issue:`2672`)

- Remove ParameterSet.deprecated_arg_dict - its not a public api and the lack
of the underscore was a naming error. (:issue:`2675`)

- Remove the internal multi-typed attribute ``Node._evalskip`` and replace it
with the boolean ``Node._skipped_by_mark``. (:issue:`2767`)

- The ``params`` list passed to ``pytest.fixture`` is now for
all effects considered immutable and frozen at the moment of the ``pytest.fixture``
call. Previously the list could be changed before the first invocation of the fixture
allowing for a form of dynamic parametrization (for example, updated from command-line options),
but this was an unwanted implementation detail which complicated the internals and prevented
some internal cleanup. See issue :issue:`2959`
for details and a recommended workaround.

Features
--------

- ``pytest_fixture_post_finalizer`` hook can now receive a ``request``
argument. (:issue:`2124`)

- Replace the old introspection code in compat.py that determines the available
arguments of fixtures with inspect.signature on Python 3 and
funcsigs.signature on Python 2. This should respect ``__signature__``
declarations on functions. (:issue:`2267`)

- Report tests with global ``pytestmark`` variable only once. (:issue:`2549`)

- Now pytest displays the total progress percentage while running tests. The
previous output style can be set by configuring the ``console_output_style``
setting to ``classic``. (:issue:`2657`)

- Match ``warns`` signature to ``raises`` by adding ``match`` keyword. (:issue:`2708`)

- pytest now captures and displays output from the standard ``logging`` module.
The user can control the logging level to be captured by specifying options
in ``pytest.ini``, the command line and also during individual tests using
markers. Also, a ``caplog`` fixture is available that enables users to test
the captured log during specific tests (similar to ``capsys`` for example).
For more information, please see the :doc:`logging docs <how-to/logging>`. This feature was
introduced by merging the popular :pypi:`pytest-catchlog` plugin, thanks to :user:`thisch`.
Be advised that during the merging the
backward compatibility interface with the defunct ``pytest-capturelog`` has
been dropped. (:issue:`2794`)

- Add ``allow_module_level`` kwarg to ``pytest.skip()``, enabling to skip the
whole module. (:issue:`2808`)

- Allow setting ``file_or_dir``, ``-c``, and ``-o`` in PYTEST_ADDOPTS. (:issue:`2824`)

- Return stdout/stderr capture results as a ``namedtuple``, so ``out`` and
``err`` can be accessed by attribute. (:issue:`2879`)

- Add ``capfdbinary``, a version of ``capfd`` which returns bytes from
``readouterr()``. (:issue:`2923`)

- Add ``capsysbinary`` a version of ``capsys`` which returns bytes from
``readouterr()``. (:issue:`2934`)

- Implement feature to skip ``setup.py`` files when run with
``--doctest-modules``. (:issue:`502`)


Bug Fixes
---------

- Resume output capturing after ``capsys/capfd.disabled()`` context manager.
(:issue:`1993`)

- ``pytest_fixture_setup`` and ``pytest_fixture_post_finalizer`` hooks are now
called for all ``conftest.py`` files. (:issue:`2124`)

- If an exception happens while loading a plugin, pytest no longer hides the
original traceback. In Python 2 it will show the original traceback with a new
message that explains in which plugin. In Python 3 it will show 2 canonized
exceptions, the original exception while loading the plugin in addition to an
exception that pytest throws about loading a plugin. (:issue:`2491`)

- ``capsys`` and ``capfd`` can now be used by other fixtures. (:issue:`2709`)

- Internal ``pytester`` plugin properly encodes ``bytes`` arguments to
``utf-8``. (:issue:`2738`)

- ``testdir`` now uses use the same method used by ``tmpdir`` to create its
temporary directory. This changes the final structure of the ``testdir``
directory slightly, but should not affect usage in normal scenarios and
avoids a number of potential problems. (:issue:`2751`)

- pytest no longer complains about warnings with unicode messages being
non-ascii compatible even for ascii-compatible messages. As a result of this,
warnings with unicode messages are converted first to an ascii representation
for safety. (:issue:`2809`)

- Change return value of pytest command when ``--maxfail`` is reached from
``2`` (interrupted) to ``1`` (failed). (:issue:`2845`)

- Fix issue in assertion rewriting which could lead it to rewrite modules which
should not be rewritten. (:issue:`2939`)

- Handle marks without description in ``pytest.ini``. (:issue:`2942`)


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

- pytest now depends on :pypi:`attrs` for internal
structures to ease code maintainability. (:issue:`2641`)

- Refactored internal Python 2/3 compatibility code to use ``six``. (:issue:`2642`)

- Stop vendoring ``pluggy`` - we're missing out on its latest changes for not
much benefit (:issue:`2719`)

- Internal refactor: simplify ascii string escaping by using the
backslashreplace error handler in newer Python 3 versions. (:issue:`2734`)

- Remove unnecessary mark evaluator in unittest plugin (:issue:`2767`)

- Calls to ``Metafunc.addcall`` now emit a deprecation warning. This function
is scheduled to be removed in ``pytest-4.0``. (:issue:`2876`)

- Internal move of the parameterset extraction to a more maintainable place.
(:issue:`2877`)

- Internal refactoring to simplify scope node lookup. (:issue:`2910`)

- Configure ``pytest`` to prevent pip from installing pytest in unsupported
Python versions. (:issue:`2922`)

3.2.5

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

Bug Fixes
---------

- Remove ``py<1.5`` restriction from ``pytest`` as this can cause version
conflicts in some installations. (:issue:`2926`)

Page 19 of 33

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.