File tree 1 file changed +12
-5
lines changed 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:
42
42
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
43
43
======================= 1 passed, 1 warning in 0.12s =======================
44
44
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:
47
57
48
58
.. code-block :: pytest
49
59
@@ -96,9 +106,6 @@ all other warnings into errors.
96
106
When a warning matches more than one option in the list, the action for the last matching option
97
107
is performed.
98
108
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.
102
109
103
110
.. _`filterwarnings` :
104
111
You can’t perform that action at this time.
0 commit comments