You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
=================== 1 passed, 1 warnings in 0.12 seconds ===================
38
38
39
-
Pytest by default catches all warnings except for ``DeprecationWarning`` and ``PendingDeprecationWarning``.
40
-
41
39
The ``-W`` flag can be passed to control which warnings will be displayed or even turn
42
40
them into errors::
43
41
@@ -78,6 +76,53 @@ Both ``-W`` command-line option and ``filterwarnings`` ini option are based on P
78
76
`-W option`_ and `warnings.simplefilter`_, so please refer to those sections in the Python
79
77
documentation for other examples and advanced usage.
80
78
79
+
Disabling warning summary
80
+
-------------------------
81
+
82
+
Although not recommended, you can use the ``--disable-warnings`` command-line option to suppress the
83
+
warning summary entirely from the test run output.
84
+
85
+
Disabling warning capture entirely
86
+
----------------------------------
87
+
88
+
This plugin is enabled by default but can be disabled entirely in your ``pytest.ini`` file with:
89
+
90
+
.. code-block:: ini
91
+
92
+
[pytest]
93
+
addopts = -p no:warnings
94
+
95
+
Or passing ``-p no:warnings`` in the command-line. This might be useful if your test suites handles warnings
96
+
using an external system.
97
+
98
+
99
+
.. _`deprecation-warnings`:
100
+
101
+
DeprecationWarning and PendingDeprecationWarning
102
+
------------------------------------------------
103
+
104
+
.. versionadded:: 3.8
105
+
106
+
By default pytest will display ``DeprecationWarning`` and ``PendingDeprecationWarning`` if no other warning filters
107
+
are configured.
108
+
109
+
To disable showing ``DeprecationWarning`` and ``PendingDeprecationWarning`` warnings, you might define any warnings
110
+
filter either in the command-line or in the ini file, or you can use:
111
+
112
+
.. code-block:: ini
113
+
114
+
[pytest]
115
+
filterwarnings =
116
+
ignore::DeprecationWarning
117
+
ignore::PendingDeprecationWarning
118
+
119
+
.. note::
120
+
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
121
+
be shown by default by test runners, but pytest doesn't follow ``PEP-0506`` completely because resetting all
122
+
warning filters like suggested in the PEP will break existing test suites that configure warning filters themselves
123
+
by calling ``warnings.simplefilter`` (see issue `#2430 <https://github.com/pytest-dev/pytest/issues/2430>`_
124
+
for an example of that).
125
+
81
126
82
127
.. _`filterwarnings`:
83
128
@@ -144,18 +189,6 @@ decorator or to all tests in a module by setting the ``pytestmark`` variable:
0 commit comments