Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge features into master #3942

Merged
merged 77 commits into from
Sep 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
126896f
Add option to disable plugin auto-loading
Aug 6, 2018
5f97711
Merge pull request #3787 from hsoft/no-plugin-autoload
nicoddemus Aug 9, 2018
c64a8c9
Merge remote-tracking branch 'upstream/master' into merge-master-into…
nicoddemus Aug 18, 2018
a6cdd0d
Merge pull request #3831 from nicoddemus/merge-master-into-features
nicoddemus Aug 18, 2018
539a22c
Added support for xfailed and xpassed outcomes to the ``pytester.RunR…
wimglenn Aug 20, 2018
044d2b8
Merge pull request #3838 from wimglenn/runresult_xfail
nicoddemus Aug 20, 2018
93f7832
Add the progress_display_mode ini option
jeffreyrack Aug 24, 2018
5fefc48
Fixing pre-commit hooks
jeffreyrack Aug 24, 2018
5e260c4
Fixing changelog file.
jeffreyrack Aug 26, 2018
dda5e5e
Fixing backticks in changelog file.
jeffreyrack Aug 26, 2018
325319d
Fixing xdist test to properly configure an ini file.
jeffreyrack Aug 26, 2018
2a917a5
Removing accidental change to test
jeffreyrack Aug 26, 2018
2f2d586
Merge remote-tracking branch 'upstream/master' into merge-master-into…
nicoddemus Aug 26, 2018
80eef29
Merge pull request #3884 from nicoddemus/merge-master-into-features
nicoddemus Aug 26, 2018
8f4685e
Move count display style to be part of console_output_style, fixed te…
jeffreyrack Aug 27, 2018
23295e1
Fix docs linting
nicoddemus Aug 27, 2018
4b94760
Removed spacing in count display.
jeffreyrack Aug 28, 2018
a605ad4
Merge pull request #3880 from jeffreyrack/3829-progress_display_mode
nicoddemus Aug 28, 2018
3035b27
T3853:removed needless message printed with --failed-first,--last-fai…
dhirensr Aug 30, 2018
ade01b1
T3853:Added changelog file
dhirensr Aug 30, 2018
0183d46
Improve CHANGELOG a bit
nicoddemus Aug 30, 2018
84a033f
Remove extra newline
nicoddemus Aug 30, 2018
64f0068
Merge pull request #3912 from dhirensr/needless_message
nicoddemus Aug 30, 2018
11e591e
Merge remote-tracking branch 'upstream/master' into merge-master-into…
nicoddemus Aug 30, 2018
2256f2f
Remove test which is no longer required and improve test_lf_and_ff_pr…
nicoddemus Aug 31, 2018
01df368
Merge pull request #3914 from nicoddemus/merge-master-into-features
RonnyPfannschmidt Aug 31, 2018
b01704c
Fix exit code for command line errors
crazymerlyn Sep 2, 2018
10f21b4
Remove assert for "reprec" because this is no longer set on the plugi…
nicoddemus Aug 25, 2018
ffd47ce
Implement new pytest_warning_captured hook
nicoddemus Aug 25, 2018
3fcc4cd
Make terminal capture pytest_warning_capture
nicoddemus Aug 26, 2018
51e32cf
Remove Python 2.6 specific warning
nicoddemus Aug 26, 2018
1a9d913
Capture and display warnings during collection
nicoddemus Aug 26, 2018
0100f61
Start the laywork to capture standard warnings
nicoddemus Aug 29, 2018
8e4501e
Use std_warn for warning about applying marks directly to parameters
nicoddemus Aug 31, 2018
0c8dbdc
Fix existing tests now that we are using standard warnings
nicoddemus Sep 1, 2018
78ac7d9
Deprecate Config.warn and Node.warn, replaced by standard warnings
nicoddemus Sep 2, 2018
19a01c9
Make PytestWarning and RemovedInPytest4Warning part of the public API
nicoddemus Sep 3, 2018
208dd3a
Add docs for internal warnings and introduce PytestDeprecationWarning
nicoddemus Sep 3, 2018
7e13593
Add CHANGELOG entries for #2452
nicoddemus Sep 3, 2018
9965ed8
Show deprecation warnings by default if no other filters are configured
nicoddemus Sep 3, 2018
60499d2
Add test to ensure that users can suppress internal warnings
nicoddemus Sep 3, 2018
0fffa6b
Implement hack to issue warnings during config
nicoddemus Sep 3, 2018
56d4141
Remove nodeid from messages for warnings generated by standard warnings
nicoddemus Sep 3, 2018
b818314
Improve docs for warnings capture and PEP-0506 remarks
nicoddemus Sep 4, 2018
8ce3aea
Move PytestExerimentalApiWarning to warning_types
nicoddemus Sep 4, 2018
415a62e
Fix typo in PytestExperimentalApiWarning
nicoddemus Sep 4, 2018
c304998
Remove commented out code
nicoddemus Sep 4, 2018
e9417be
Add comment about deprecation warnings being shown by default
nicoddemus Sep 4, 2018
016f8f1
Improve get_fslocation_from_item's docstring
nicoddemus Sep 4, 2018
29bfa5e
Merge pull request #3925 from crazymerlyn/fix-exit-code
nicoddemus Sep 4, 2018
615c671
Connect string literals
nicoddemus Sep 4, 2018
9ae0a3c
Do not trigger warning about tuples being always True if the tuple ha…
nicoddemus Sep 4, 2018
284a2d1
Move warnings import to top level
nicoddemus Sep 4, 2018
b42518a
Change std_warn to receive a single warning instance, addressed revie…
nicoddemus Sep 4, 2018
022c58b
Revert pytest_terminal_summary(tryfirst) in warnings module as this b…
nicoddemus Sep 4, 2018
d3f72ca
Fix linting for warnings.rst
nicoddemus Sep 4, 2018
f1cfd10
Handle cache warnings in tests
nicoddemus Sep 4, 2018
a054aa4
Issue assert rewrite warning if tuple >=1 as suggested in review
nicoddemus Sep 4, 2018
5ef5126
Fix reference to PytestWarning in warningsfilter mark
nicoddemus Sep 4, 2018
47bf58d
Make Node.warn support two forms, new and deprecated
nicoddemus Sep 4, 2018
438f7a1
Add "setup", "call" and "teardown" values to "when" parameter of pyte…
nicoddemus Sep 4, 2018
3db76cc
Fix Cache.warn function to issue a "config" warning
nicoddemus Sep 4, 2018
d3ca739
Use explicit instances when calling warnings.warn_explicit
nicoddemus Sep 4, 2018
b7560a8
Keep backward compatibility for code as kw in Node.warn
nicoddemus Sep 4, 2018
6d497f2
Fix stacklevel for warning about Metafunc.addcall
nicoddemus Sep 4, 2018
5a52aca
Make config no longer optional in parametrize id functions
nicoddemus Sep 4, 2018
2e0a7cf
Revert to having just "runtest" as "when" parameter of the pytest_war…
nicoddemus Sep 4, 2018
4592def
Improve test_rewarn_functional
nicoddemus Sep 4, 2018
adc9ed8
Fix test_idval_hypothesis
nicoddemus Sep 4, 2018
f42b501
Make code_or_warning parameter private for backward-compatibility
nicoddemus Sep 4, 2018
ddb3084
Make sure warn is called in test_parameterset_extractfrom
nicoddemus Sep 5, 2018
f63c683
No longer escape regex in pytest.mark.filterwarnings
nicoddemus Sep 5, 2018
531b76a
Merge pull request #3931 from nicoddemus/internal-warnings
nicoddemus Sep 5, 2018
69b34f7
Merge remote-tracking branch 'upstream/master' into release-3.8.0
nicoddemus Sep 5, 2018
1f20626
Preparing release version 3.8.0
nicoddemus Sep 5, 2018
f2a427d
Merge pull request #3940 from nicoddemus/release-3.8.0
nicoddemus Sep 6, 2018
8c4ca38
Merge remote-tracking branch 'upstream/features' into merge-features-…
nicoddemus Sep 6, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Christian Boelsen
Christian Theunert
Christian Tismer
Christopher Gilling
CrazyMerlyn
Cyrus Maden
Dhiren Serai
Daniel Grana
Expand Down Expand Up @@ -212,10 +213,12 @@ Vasily Kuznetsov
Victor Maryama
Victor Uriarte
Vidar T. Fauske
Virgil Dupras
Vitaly Lashmanov
Vlad Dragos
Wil Cooley
William Lee
Wim Glenn
Wouter van Ackooy
Xuan Luong
Xuecong Liao
Expand Down
84 changes: 84 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,90 @@ with advance notice in the **Deprecations** section of releases.

.. towncrier release notes start

pytest 3.8.0 (2018-09-05)
=========================

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

- `#2452 <https://github.com/pytest-dev/pytest/issues/2452>`_: ``Config.warn`` has been deprecated, it should be replaced by calls to the standard ``warnings.warn``.

``Node.warn`` now supports two signatures:

* ``node.warn(PytestWarning("some message"))``: is now the recommended way to call this function. The warning
instance must be a ``PytestWarning`` or subclass instance.

* ``node.warn("CI", "some message")``: this code/message form is now deprecated and should be converted to
the warning instance form above.

``RemovedInPytest4Warning`` and ``PytestExperimentalApiWarning`` are now part of the public API and should be accessed
using ``pytest.RemovedInPytest4Warning`` and ``pytest.PytestExperimentalApiWarning``.


- `#3936 <https://github.com/pytest-dev/pytest/issues/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
--------

- `#2452 <https://github.com/pytest-dev/pytest/issues/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 `the documentation <https://docs.pytest.org/en/latest/warnings.html#internal-pytest-warnings>`_ for more info.


- `#2908 <https://github.com/pytest-dev/pytest/issues/2908>`_: ``DeprecationWarning`` and ``PendingDeprecationWarning`` are now shown by default if no other warning filter is
configured. This makes pytest more compliant with
`PEP-0506 <https://www.python.org/dev/peps/pep-0565/#recommended-filter-settings-for-test-runners>`_. See
`the docs <https://docs.pytest.org/en/latest/warnings.html#deprecationwarning-and-pendingdeprecationwarning>`_ for
more info.


- `#3784 <https://github.com/pytest-dev/pytest/issues/3784>`_: Add option to disable plugin auto-loading.


- `#3829 <https://github.com/pytest-dev/pytest/issues/3829>`_: Added the ``count`` option to ``console_output_style`` to enable displaying the progress as a count instead of a percentage.


- `#3837 <https://github.com/pytest-dev/pytest/issues/3837>`_: Added support for 'xfailed' and 'xpassed' outcomes to the ``pytester.RunResult.assert_outcomes`` signature.



Bug Fixes
---------

- `#3911 <https://github.com/pytest-dev/pytest/issues/3911>`_: Terminal writer now takes into account unicode character width when writing out progress.


- `#3913 <https://github.com/pytest-dev/pytest/issues/3913>`_: Pytest now returns with correct exit code (EXIT_USAGEERROR, 4) when called with unknown arguments.


- `#3918 <https://github.com/pytest-dev/pytest/issues/3918>`_: Improve performance of assertion rewriting.



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

- `#3566 <https://github.com/pytest-dev/pytest/issues/3566>`_: Added a blurb in usage.rst for the usage of -r flag which is used to show an extra test summary info.


- `#3907 <https://github.com/pytest-dev/pytest/issues/3907>`_: Corrected type of the exceptions collection passed to ``xfail``: ``raises`` argument accepts a ``tuple`` instead of ``list``.



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

- `#3853 <https://github.com/pytest-dev/pytest/issues/3853>`_: Removed ``"run all (no recorded failures)"`` message printed with ``--failed-first`` and ``--last-failed`` when there are no failed tests.


pytest 3.7.4 (2018-08-29)
=========================

Expand Down
1 change: 1 addition & 0 deletions changelog/3251.feture.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Warnings are now captured and displayed during test collection.
1 change: 0 additions & 1 deletion changelog/3566.doc.rst

This file was deleted.

1 change: 0 additions & 1 deletion changelog/3907.doc.rst

This file was deleted.

1 change: 0 additions & 1 deletion changelog/3911.bugfix.rst

This file was deleted.

1 change: 0 additions & 1 deletion changelog/3918.bugfix.rst

This file was deleted.

1 change: 1 addition & 0 deletions doc/en/announce/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Release announcements
:maxdepth: 2


release-3.8.0
release-3.7.4
release-3.7.3
release-3.7.2
Expand Down
38 changes: 38 additions & 0 deletions doc/en/announce/release-3.8.0.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
pytest-3.8.0
=======================================

The pytest team is proud to announce the 3.8.0 release!

pytest is a mature Python testing tool with more than a 2000 tests
against itself, passing on many different interpreters and platforms.

This release contains a number of bugs fixes and improvements, so users are encouraged
to take a look at the CHANGELOG:

https://docs.pytest.org/en/latest/changelog.html

For complete documentation, please visit:

https://docs.pytest.org/en/latest/

As usual, you can upgrade from pypi via:

pip install -U pytest

Thanks to all who contributed to this release, among them:

* Anthony Sottile
* Bruno Oliveira
* CrazyMerlyn
* Daniel Hahler
* Fabio Zadrozny
* Jeffrey Rackauckas
* Ronny Pfannschmidt
* Virgil Dupras
* dhirensr
* hoefling
* wim glenn


Happy testing,
The Pytest Development Team
6 changes: 3 additions & 3 deletions doc/en/example/reportingdemo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -613,9 +613,9 @@ get on the terminal - we are working on that)::

failure_demo.py:261: AssertionError
============================= warnings summary =============================
<undetermined location>
Metafunc.addcall is deprecated and scheduled to be removed in pytest 4.0.
Please use Metafunc.parametrize instead.
$REGENDOC_TMPDIR/assertion/failure_demo.py:24: RemovedInPytest4Warning: Metafunc.addcall is deprecated and scheduled to be removed in pytest 4.0.
Please use Metafunc.parametrize instead.
metafunc.addcall(funcargs=dict(param1=3, param2=6))

-- Docs: https://docs.pytest.org/en/latest/warnings.html
================== 42 failed, 1 warnings in 0.12 seconds ===================
8 changes: 8 additions & 0 deletions doc/en/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,8 @@ Session related reporting hooks:
.. autofunction:: pytest_terminal_summary
.. autofunction:: pytest_fixture_setup
.. autofunction:: pytest_fixture_post_finalizer
.. autofunction:: pytest_logwarning
.. autofunction:: pytest_warning_captured

And here is the central hook for reporting about
test execution:
Expand Down Expand Up @@ -866,6 +868,11 @@ Contains comma-separated list of modules that should be loaded as plugins:

export PYTEST_PLUGINS=mymodule.plugin,xdist

PYTEST_DISABLE_PLUGIN_AUTOLOAD
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

When set, disables plugin auto-loading through setuptools entrypoints. Only explicitly specified plugins will be
loaded.

PYTEST_CURRENT_TEST
~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -935,6 +942,7 @@ passed multiple times. The expected format is ``name=value``. For example::

* ``classic``: classic pytest output.
* ``progress``: like classic pytest output, but with a progress indicator.
* ``count``: like progress, but shows progress as the number of tests completed instead of a percent.

The default is ``progress``, but you can fallback to ``classic`` if you prefer or
the new mode is causing unexpected problems:
Expand Down
19 changes: 10 additions & 9 deletions doc/en/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,12 @@ making it easy in large test suites to get a clear picture of all failures, skip
Example::

$ pytest -ra
======================== test session starts ========================
...
====================== short test summary info ======================
FAIL summary\test_foo.py::test_1
SKIP [1] summary\test_foo.py:12: not supported in this platform
XPASS summary\test_bar.py::test_4 flaky

===== 1 failed, 1 passed, 1 skipped, 1 xpassed in 0.08 seconds ======
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-3.x.y, py-1.x.y, pluggy-0.x.y
rootdir: $REGENDOC_TMPDIR, inifile:
collected 0 items

======================= no tests ran in 0.12 seconds =======================

The ``-r`` options accepts a number of characters after it, with ``a`` used above meaning "all except passes".

Expand All @@ -179,8 +176,12 @@ Here is the full list of available characters that can be used:
More than one character can be used, so for example to only see failed and skipped tests, you can execute::

$ pytest -rfs
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-3.x.y, py-1.x.y, pluggy-0.x.y
rootdir: $REGENDOC_TMPDIR, inifile:
collected 0 items


======================= no tests ran in 0.12 seconds =======================

.. _pdb-option:

Expand Down
114 changes: 97 additions & 17 deletions doc/en/warnings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,12 @@ Running pytest now produces this output::
test_show_warnings.py . [100%]

============================= warnings summary =============================
test_show_warnings.py::test_one
$REGENDOC_TMPDIR/test_show_warnings.py:4: UserWarning: api v1, should use functions from v2
warnings.warn(UserWarning("api v1, should use functions from v2"))
$REGENDOC_TMPDIR/test_show_warnings.py:4: UserWarning: api v1, should use functions from v2
warnings.warn(UserWarning("api v1, should use functions from v2"))

-- Docs: https://docs.pytest.org/en/latest/warnings.html
=================== 1 passed, 1 warnings in 0.12 seconds ===================

Pytest by default catches all warnings except for ``DeprecationWarning`` and ``PendingDeprecationWarning``.

The ``-W`` flag can be passed to control which warnings will be displayed or even turn
them into errors::

Expand Down Expand Up @@ -78,6 +75,53 @@ Both ``-W`` command-line option and ``filterwarnings`` ini option are based on P
`-W option`_ and `warnings.simplefilter`_, so please refer to those sections in the Python
documentation for other examples and advanced usage.

Disabling warning summary
-------------------------

Although not recommended, you can use the ``--disable-warnings`` command-line option to suppress the
warning summary entirely from the test run output.

Disabling warning capture entirely
----------------------------------

This plugin is enabled by default but can be disabled entirely in your ``pytest.ini`` file with:

.. code-block:: ini

[pytest]
addopts = -p no:warnings

Or passing ``-p no:warnings`` in the command-line. This might be useful if your test suites handles warnings
using an external system.


.. _`deprecation-warnings`:

DeprecationWarning and PendingDeprecationWarning
------------------------------------------------

.. versionadded:: 3.8

By default pytest will display ``DeprecationWarning`` and ``PendingDeprecationWarning`` if no other warning filters
are configured.

To disable showing ``DeprecationWarning`` and ``PendingDeprecationWarning`` warnings, you might define any warnings
filter either in the command-line or in the ini file, or you can use:

.. code-block:: ini

[pytest]
filterwarnings =
ignore::DeprecationWarning
ignore::PendingDeprecationWarning

.. note::
This makes pytest more compliant with `PEP-0506 <https://www.python.org/dev/peps/pep-0565/#recommended-filter-settings-for-test-runners>`_ which suggests that those warnings should
be shown by default by test runners, but pytest doesn't follow ``PEP-0506`` completely because resetting all
warning filters like suggested in the PEP will break existing test suites that configure warning filters themselves
by calling ``warnings.simplefilter`` (see issue `#2430 <https://github.com/pytest-dev/pytest/issues/2430>`_
for an example of that).


.. _`filterwarnings`:

Expand Down Expand Up @@ -144,18 +188,6 @@ decorator or to all tests in a module by setting the ``pytestmark`` variable:
.. _`pytest-warnings`: https://github.com/fschulze/pytest-warnings


Disabling warning capture
-------------------------

This feature is enabled by default but can be disabled entirely in your ``pytest.ini`` file with:

.. code-block:: ini

[pytest]
addopts = -p no:warnings

Or passing ``-p no:warnings`` in the command-line.

.. _`asserting warnings`:

.. _assertwarnings:
Expand Down Expand Up @@ -296,3 +328,51 @@ You can also use it as a contextmanager::
def test_global():
with pytest.deprecated_call():
myobject.deprecated_method()


Internal pytest warnings
------------------------

.. versionadded:: 3.8

pytest may generate its own warnings in some situations, such as improper usage or deprecated features.

For example, pytest will emit a warning if it encounters a class that matches :confval:`python_classes` but also
defines an ``__init__`` constructor, as this prevents the class from being instantiated:

.. code-block:: python

# content of test_pytest_warnings.py
class Test:
def __init__(self):
pass

def test_foo(self):
assert 1 == 1

::

$ pytest test_pytest_warnings.py -q

============================= warnings summary =============================
$REGENDOC_TMPDIR/test_pytest_warnings.py:1: PytestWarning: cannot collect test class 'Test' because it has a __init__ constructor
class Test:

-- Docs: https://docs.pytest.org/en/latest/warnings.html
1 warnings in 0.12 seconds

These warnings might be filtered using the same builtin mechanisms used to filter other types of warnings.

Following our :ref:`backwards-compatibility`, deprecated features will be kept *at least* two minor releases. After that,
they will changed so they by default raise errors instead of just warnings, so users can adapt to it on their own time
if not having done so until now. In a later release the deprecated feature will be removed completely.

The following warning types ares used by pytest and are part of the public API:

.. autoclass:: pytest.PytestWarning

.. autoclass:: pytest.PytestDeprecationWarning

.. autoclass:: pytest.RemovedInPytest4Warning

.. autoclass:: pytest.PytestExperimentalApiWarning
Loading