File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -42,8 +42,18 @@ Running pytest now produces this output:
4242 -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
4343 ======================= 1 passed, 1 warning in 0.12s =======================
4444
45- The ``-W `` flag can be passed to control which warnings will be displayed or even turn
46- them into errors:
45+ Controlling warnings
46+ --------------------
47+
48+ Similar to Python's `warning filter `_ and :option: `-W option <python:-W> ` flag, pytest provides
49+ its own ``-W `` flag to control which warnings are ignored, displayed, or turned into
50+ errors. See the `warning filter `_ documentation for more
51+ advanced use-cases.
52+
53+ .. _`warning filter` : https://docs.python.org/3/library/warnings.html#warning-filter
54+
55+ This code sample shows how to treat any ``UserWarning `` category class of warning
56+ as an error:
4757
4858.. code-block :: pytest
4959
@@ -96,9 +106,6 @@ all other warnings into errors.
96106 When a warning matches more than one option in the list, the action for the last matching option
97107is performed.
98108
99- Both ``-W `` command-line option and ``filterwarnings `` ini option are based on Python's own
100- :option: `-W option <python:-W> ` and :func: `warnings.simplefilter `, so please refer to those sections in the Python
101- documentation for other examples and advanced usage.
102109
103110.. _`filterwarnings` :
104111
You can’t perform that action at this time.
0 commit comments