From 81a5e92fc693f55101fd722f3be61fc781fa0a64 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Fri, 27 Jan 2023 08:04:13 -0300 Subject: [PATCH] Fix code-block --- doc/en/how-to/capture-warnings.rst | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/doc/en/how-to/capture-warnings.rst b/doc/en/how-to/capture-warnings.rst index 4fa48efa0..51e85badd 100644 --- a/doc/en/how-to/capture-warnings.rst +++ b/doc/en/how-to/capture-warnings.rst @@ -276,23 +276,27 @@ first be escaped with ``re.escape``. Some examples: -.. code-block: python +.. code-block:: pycon - >>> with warns(UserWarning, match='must be 0 or None'): + >>> with warns(UserWarning, match="must be 0 or None"): ... warnings.warn("value must be 0 or None", UserWarning) + ... - >>> with warns(UserWarning, match=r'must be \d+$'): + >>> with warns(UserWarning, match=r"must be \d+$"): ... warnings.warn("value must be 42", UserWarning) + ... - >>> with warns(UserWarning, match=r'must be \d+$'): + >>> with warns(UserWarning, match=r"must be \d+$"): ... warnings.warn("this is not here", UserWarning) + ... Traceback (most recent call last): ... Failed: DID NOT WARN. No warnings of type ...UserWarning... were emitted... - >>> with warns(UserWarning, match=re.escape('issue with foo() func')): + >>> with warns(UserWarning, match=re.escape("issue with foo() func")): ... warnings.warn("issue with foo() func") + ... You can also call :func:`pytest.warns` on a function or code string: