def test_should_build_negated_description(self): matcher = RaisesMatcher(ValueError) self.assertEquals("Expected 'spam' not to raise exception of type ValueError", matcher.describe_negated("spam"))
def test_should_build_negated_description(self): matcher = RaisesMatcher(ValueError) self.assertEquals( "Expected 'spam' not to raise exception of type ValueError", matcher.describe_negated("spam"))
def test_should_build_description(self): matcher = RaisesMatcher(ValueError) matcher._actual_exception_type = TypeError self.assertEquals("Expected 'spam' to raise exception of type ValueError but instead caught TypeError", matcher.describe("spam"))
def test_should_not_match_callable_raising_no_exception(self): def closure(): pass self.assertFalse(RaisesMatcher(ValueError).matches(closure))
def test_should_build_description(self): matcher = RaisesMatcher(ValueError) matcher._actual_exception_type = TypeError self.assertEquals( "Expected 'spam' to raise exception of type ValueError but instead caught TypeError", matcher.describe("spam"))
def test_should_not_match_callable_raising_unexpected_exception(self): def closure(): raise TypeError() self.assertFalse(RaisesMatcher(ValueError).matches(closure))
def test_should_match_callable_raising_expected_exception(self): def closure(): raise ValueError() self.assertTrue(RaisesMatcher(ValueError).matches(closure))
def test_should_not_accept_object_without_call_function(self): class NotCallable: pass self.assertFalse(RaisesMatcher(BaseException).accepts(NotCallable()))
def test_should_accept_object_with_call_function(self): class Callable: def __call__(self): pass self.assertTrue(RaisesMatcher(BaseException).accepts(Callable()))
def test_should_accept_function(self): def fun(): pass self.assertTrue(RaisesMatcher(BaseException).accepts(fun))