Skip to content

Commit 02c6e44

Browse files
document toml use of filterwarnings (#7611)
and include a demo of toml 'literal strings' Update doc/en/warnings.rst Apply suggestion by Ran Fix linting Co-authored-by: Bruno Oliveira <[email protected]>
1 parent 10f98e1 commit 02c6e44

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

doc/en/warnings.rst

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,30 @@ them into errors:
6868
FAILED test_show_warnings.py::test_one - UserWarning: api v1, should use ...
6969
1 failed in 0.12s
7070
71-
The same option can be set in the ``pytest.ini`` file using the ``filterwarnings`` ini option.
72-
For example, the configuration below will ignore all user warnings, but will transform
71+
The same option can be set in the ``pytest.ini`` or ``pyproject.toml`` file using the
72+
``filterwarnings`` ini option. For example, the configuration below will ignore all
73+
user warnings and specific deprecation warnings matching a regex, but will transform
7374
all other warnings into errors.
7475

7576
.. code-block:: ini
7677
78+
# pytest.ini
7779
[pytest]
7880
filterwarnings =
7981
error
8082
ignore::UserWarning
83+
ignore:function ham\(\) is deprecated:DeprecationWarning
84+
85+
.. code-block:: toml
86+
87+
# pyproject.toml
88+
[tool.pytest.ini_options]
89+
filterwarnings = [
90+
"error",
91+
"ignore::UserWarning",
92+
# note the use of single quote below to denote "raw" strings in TOML
93+
'ignore:function ham\(\) is deprecated:DeprecationWarning',
94+
]
8195
8296
8397
When a warning matches more than one option in the list, the action for the last matching option

0 commit comments

Comments
 (0)