Skip to content

Commit af99040

Browse files
authored
Add a note about -W vs filterwarnings. (pytest-dev#10713)
Closes pytest-dev#10687 Signed-off-by: mvashishtha <mahesh@ponder.io>
1 parent a2b7db7 commit af99040

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
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)