From 02c6e4455c183f1e3c9c2dacf0904a0d17fd111d Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Fri, 14 Aug 2020 08:08:17 +0100 Subject: [PATCH] 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 --- doc/en/warnings.rst | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/doc/en/warnings.rst b/doc/en/warnings.rst index d1e27ecad..fe2ef39dc 100644 --- a/doc/en/warnings.rst +++ b/doc/en/warnings.rst @@ -68,16 +68,30 @@ them into errors: FAILED test_show_warnings.py::test_one - UserWarning: api v1, should use ... 1 failed in 0.12s -The same option can be set in the ``pytest.ini`` file using the ``filterwarnings`` ini option. -For example, the configuration below will ignore all user warnings, but will transform +The same option can be set in the ``pytest.ini`` or ``pyproject.toml`` file using the +``filterwarnings`` ini option. For example, the configuration below will ignore all +user warnings and specific deprecation warnings matching a regex, but will transform all other warnings into errors. .. code-block:: ini + # pytest.ini [pytest] filterwarnings = error ignore::UserWarning + ignore:function ham\(\) is deprecated:DeprecationWarning + +.. code-block:: toml + + # pyproject.toml + [tool.pytest.ini_options] + filterwarnings = [ + "error", + "ignore::UserWarning", + # note the use of single quote below to denote "raw" strings in TOML + 'ignore:function ham\(\) is deprecated:DeprecationWarning', + ] When a warning matches more than one option in the list, the action for the last matching option