Skip to content

Commit 02e9e84

Browse files
authored
Merge pull request #10715 from pytest-dev/backport-10713-to-7.2.x
[7.2.x] DOCS-#10687: Add a note about -W vs filterwarnings.
2 parents d61f83c + 7e1549d commit 02e9e84

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

doc/en/how-to/capture-warnings.rst

+12
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,18 @@ When a warning matches more than one option in the list, the action for the last
109109
is performed.
110110

111111

112+
.. note::
113+
114+
The ``-W`` flag and the ``filterwarnings`` ini option use warning filters that are
115+
similar in structure, but each configuration option interprets its filter
116+
differently. For example, *message* in ``filterwarnings`` is a string containing a
117+
regular expression that the start of the warning message must match,
118+
case-insensitively, while *message* in ``-W`` is a literal string that the start of
119+
the warning message must contain (case-insensitively), ignoring any whitespace at
120+
the start or end of message. Consult the `warning filter`_ documentation for more
121+
details.
122+
123+
112124
.. _`filterwarnings`:
113125

114126
``@pytest.mark.filterwarnings``

0 commit comments

Comments
 (0)