def test_fails_when_exception_test_fails(self): """Tests that when an exception of the right type that fails the passed in exception test is raised, the assertion fails.""" has_two_args = lambda e: assertions.assert_length(e.args, 2) with assertions.assert_raises(AssertionError): with assertions.assert_raises_such_that(Exception, has_two_args): raise Exception("only one argument")
def test_passes_when_correct_exception_is_raised(self): """Tests that when an exception of the right type that passes the exception test is raised, the assertion passes.""" has_two_args = lambda e: assertions.assert_length(e.args, 2) with assertions.assert_raises_such_that(Exception, has_two_args): raise Exception("first", "second")
def has_two_args(e): assertions.assert_length(e.args, 2)