From dca18cbeda9eea0c534e777efd332dd02571a41c Mon Sep 17 00:00:00 2001 From: Fady Morris Ebeid Date: Tue, 30 Jun 2026 11:45:26 +0300 Subject: [PATCH] Update assertion to use issubclass for RuntimeError Change assertion to check for subclass of RuntimeError. --- doc/en/how-to/assert.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/en/how-to/assert.rst b/doc/en/how-to/assert.rst index 43aeb66fdfc..d05b6e8ebad 100644 --- a/doc/en/how-to/assert.rst +++ b/doc/en/how-to/assert.rst @@ -137,7 +137,7 @@ If you want to check if a block of code is raising an exact exception type, you with pytest.raises(RuntimeError) as excinfo: foo() - assert excinfo.type is RuntimeError + assert issubclass(excinfo.type, 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