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"))
Esempio n. 2
0
 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"))
Esempio n. 4
0
    def test_should_not_match_callable_raising_no_exception(self):
        def closure():
            pass

        self.assertFalse(RaisesMatcher(ValueError).matches(closure))
Esempio n. 5
0
 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"))
Esempio n. 6
0
    def test_should_not_match_callable_raising_unexpected_exception(self):
        def closure():
            raise TypeError()

        self.assertFalse(RaisesMatcher(ValueError).matches(closure))
Esempio n. 7
0
    def test_should_match_callable_raising_expected_exception(self):
        def closure():
            raise ValueError()

        self.assertTrue(RaisesMatcher(ValueError).matches(closure))
Esempio n. 8
0
    def test_should_not_accept_object_without_call_function(self):
        class NotCallable:
            pass

        self.assertFalse(RaisesMatcher(BaseException).accepts(NotCallable()))
Esempio n. 9
0
    def test_should_accept_object_with_call_function(self):
        class Callable:
            def __call__(self):
                pass

        self.assertTrue(RaisesMatcher(BaseException).accepts(Callable()))
Esempio n. 10
0
    def test_should_accept_function(self):
        def fun():
            pass

        self.assertTrue(RaisesMatcher(BaseException).accepts(fun))