== Why is this an issue? Using ``++pytest.raises++`` or ``++unittest.TestCase.assertRaises++`` will assert that an exception is raised in the following block. Ending such block in an assertion means that the test can succeed with that last assertion never being executed. === Noncompliant code example [source,python] ---- import pytest def foo(): return 1 / 0 def bar(): return 42 def test_something(): with pytest.raises(ZeroDivisionError): foo() assert bar() == 42 # Noncompliant ---- === Compliant solution [source,python] ---- import pytest def foo(): return 1 / 0 def bar(): return 42 def test_something(): with pytest.raises(ZeroDivisionError): foo() assert bar() == 42 ---- == Resources * https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertRaises[Unittest: assertRaises] * https://docs.pytest.org/en/stable/assert.html#assertions-about-expected-exceptions[Pytest: assertions about expected exceptions] ifdef::env-github,rspecator-view[] ''' == Implementation Specification (visible only on this page) include::../message.adoc[] include::../highlighting.adoc[] endif::env-github,rspecator-view[]