Skip to content

Commit 4ae47b7

Browse files
committed
doc: always use raw TOML strings in filterwarnings examples
When regexes are involved they're the better choice.
1 parent e563b9a commit 4ae47b7

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

doc/en/how-to/capture-warnings.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ all other warnings into errors.
9191
9292
[pytest]
9393
filterwarnings = [
94-
"error",
95-
"ignore::UserWarning",
96-
# note the use of single quote below to denote "raw" strings in TOML
94+
'error',
95+
'ignore::UserWarning',
96+
# Note the use of single quote below to denote "raw" strings in TOML.
9797
'ignore:function ham\(\) is deprecated:DeprecationWarning',
9898
]
9999

doc/en/reference/reference.rst

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ Add warning filters to marked test items.
186186

187187
.. code-block:: python
188188
189-
@pytest.mark.filterwarnings("ignore:.*usage will be deprecated.*:DeprecationWarning")
189+
@pytest.mark.filterwarnings(r"ignore:.*usage will be deprecated.*:DeprecationWarning")
190190
def test_foo(): ...
191191
192192
@@ -1587,9 +1587,8 @@ passed multiple times. The expected format is ``name=value``. For example::
15871587
For more information please refer to :ref:`faulthandler`.
15881588
For more information please refer to :ref:`faulthandler`.
15891589

1590-
.. confval:: filterwarnings
1591-
15921590

1591+
.. confval:: filterwarnings
15931592

15941593
Sets a list of filters and actions that should be taken for matched
15951594
warnings. By default all warnings emitted during the test session
@@ -1600,7 +1599,12 @@ passed multiple times. The expected format is ``name=value``. For example::
16001599
.. code-block:: toml
16011600
16021601
[pytest]
1603-
filterwarnings = ["error", "ignore::DeprecationWarning"]
1602+
filterwarnings = [
1603+
'error',
1604+
'ignore::DeprecationWarning',
1605+
# Note the use of single quote below to denote "raw" strings in TOML.
1606+
'ignore:function ham\(\) should not be used:UserWarning',
1607+
]
16041608
16051609
.. tab:: ini
16061610

@@ -1610,6 +1614,7 @@ passed multiple times. The expected format is ``name=value``. For example::
16101614
filterwarnings =
16111615
error
16121616
ignore::DeprecationWarning
1617+
ignore:function ham\(\) should not be used:UserWarning
16131618
16141619
This tells pytest to ignore deprecation warnings and turn all other warnings
16151620
into errors. For more information please refer to :ref:`warnings`.

0 commit comments

Comments
 (0)