From 70f03dbc3e6f5f7bd81a26d040a39f02f97d460f Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sat, 4 Nov 2023 12:37:47 -0300 Subject: [PATCH] Adjustments to assert raises docs (#11586) Followup from #11578. --- doc/en/how-to/assert.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/en/how-to/assert.rst b/doc/en/how-to/assert.rst index 1401064d7..7d5076a50 100644 --- a/doc/en/how-to/assert.rst +++ b/doc/en/how-to/assert.rst @@ -104,13 +104,13 @@ If you want to check if a block of code is raising an exact exception type, you .. code-block:: python - def test_recursion_depth(): + def test_foo_not_implemented(): def foo(): raise NotImplementedError with pytest.raises(RuntimeError) as excinfo: foo() - assert type(excinfo.value) is RuntimeError + assert excinfo.type is RuntimeError The :func:`pytest.raises` call will succeed, even though the function raises :class:`NotImplementedError`, because :class:`NotImplementedError` is a subclass of :class:`RuntimeError`; however the following `assert` statement will