def test_fails_when_no_exception_is_raised(self): with assert_raises_assertion( "Expected code to raise <class 'tests.ExpectedError'>"): with expect.raises(ExpectedError): pass
def test_allows_unexpected_exception_to_bubble_up(self): with assert_raises(ActualError, 'Unexpected exception should bubble up'): with expect.raises(ExpectedError): raise ActualError('Unexpected exception should bubble up')
def test_passes_for_expected_exception(self): with expect.raises(ExpectedError): raise ExpectedError