@@ -80,30 +80,20 @@ as an error:
8080 FAILED test_show_warnings.py::test_one - UserWarning: api v1, should use ...
8181 1 failed in 0.12s
8282
83- The same option can be set in the `` pytest.ini `` or `` pyproject.toml `` file using the
84- `` filterwarnings `` ini option. For example, the configuration below will ignore all
83+ The same option can be set in the configuration file using the
84+ :confval: ` filterwarnings ` configuration option. For example, the configuration below will ignore all
8585user warnings and specific deprecation warnings matching a regex, but will transform
8686all other warnings into errors.
8787
88- .. code-block :: ini
88+ .. tab :: ini
8989
90- # pytest.ini
91- [pytest]
92- filterwarnings =
93- error
94- ignore::UserWarning
95- ignore:function ham\(\) is deprecated:DeprecationWarning
96-
97- .. code-block :: toml
90+ .. code-block :: ini
9891
99- # pyproject.toml
100- [tool.pytest.ini_options]
101- filterwarnings = [
102- "error",
103- "ignore::UserWarning",
104- # note the use of single quote below to denote "raw" strings in TOML
105- 'ignore:function ham\(\) is deprecated:DeprecationWarning',
106- ]
92+ [pytest]
93+ filterwarnings =
94+ error
95+ ignore::UserWarning
96+ ignore:function ham\(\) is deprecated:DeprecationWarning
10797
10898
10999 When a warning matches more than one option in the list, the action for the last matching option
@@ -112,7 +102,7 @@ is performed.
112102
113103.. note ::
114104
115- The ``-W `` flag and the `` filterwarnings `` ini option use warning filters that are
105+ The ``-W `` flag and the :confval: ` filterwarnings ` configuration option use warning filters that are
116106 similar in structure, but each configuration option interprets its filter
117107 differently. For example, *message * in ``filterwarnings `` is a string containing a
118108 regular expression that the start of the warning message must match,
@@ -169,7 +159,7 @@ You can specify multiple filters with separate decorators:
169159
170160
171161Filters applied using a mark take precedence over filters passed on the command line or configured
172- by the :confval: `filterwarnings ` ini option.
162+ by the :confval: `filterwarnings ` configuration option.
173163
174164You may apply a filter to all tests of a class by using the :ref: `filterwarnings <pytest.mark.filterwarnings ref >` mark as a class
175165decorator or to all tests in a module by setting the :globalvar: `pytestmark ` variable:
@@ -202,7 +192,9 @@ warning summary entirely from the test run output.
202192Disabling warning capture entirely
203193----------------------------------
204194
205- This plugin is enabled by default but can be disabled entirely in your ``pytest.ini `` file with:
195+ This plugin is enabled by default but can be disabled entirely in your configuration file with:
196+
197+ .. tab :: ini
206198
207199 .. code-block :: ini
208200
@@ -227,16 +219,18 @@ However, in the specific case where users capture any type of warnings in their
227219no warning will be displayed at all.
228220
229221Sometimes it is useful to hide some specific deprecation warnings that happen in code that you have no control over
230- (such as third-party libraries), in which case you might use the warning filters options (ini or marks) to ignore
222+ (such as third-party libraries), in which case you might use the warning filters options (configuration or marks) to ignore
231223those warnings.
232224
233225For example:
234226
235- .. code-block :: ini
227+ .. tab :: ini
236228
237- [pytest]
238- filterwarnings =
239- ignore:.*U.*mode is deprecated:DeprecationWarning
229+ .. code-block :: ini
230+
231+ [pytest]
232+ filterwarnings =
233+ ignore:.*U.*mode is deprecated:DeprecationWarning
240234
241235
242236 This will ignore all warnings of type ``DeprecationWarning `` where the start of the message matches
0 commit comments