def test_unexpected_exception_passes_through(self): class DifferentException(Exception): pass with assertions.assert_raises(DifferentException): with assertions.assert_raises_exactly(self.MyException, "first", "second"): raise DifferentException("first", "second")
def test_fails_with_different_class(self): class SpecialException(self.MyException): pass with assertions.assert_raises(AssertionError): with assertions.assert_raises_exactly(self.MyException, "first", "second"): raise SpecialException("first", "second")
def test_fails_with_vague_class(self): with assertions.assert_raises(AssertionError): with assertions.assert_raises_exactly(Exception, "first", "second"): raise self.MyException("first", "second")
def test_fails_with_wrong_value(self): with assertions.assert_raises(AssertionError): with assertions.assert_raises_exactly(self.MyException, "first", "second"): raise self.MyException("red", "blue")
def test_passes_when_correct_exception_is_raised(self): with assertions.assert_raises_exactly(self.MyException, "first", "second"): raise self.MyException("first", "second")
def test_assert_falsey_with_msg(self): with assertions.assert_raises_exactly(AssertionError, 'my_msg'): assert_falsey(1, message='my_msg')
def test_assert_truthy_with_msg(self): with assertions.assert_raises_exactly(AssertionError, 'my_msg'): assert_truthy(0, message='my_msg')