コード例 #1
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"))
コード例 #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"))
コード例 #3
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"))
コード例 #4
0
    def test_should_not_match_callable_raising_no_exception(self):
        def closure():
            pass

        self.assertFalse(RaisesMatcher(ValueError).matches(closure))
コード例 #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"))
コード例 #6
0
    def test_should_not_match_callable_raising_unexpected_exception(self):
        def closure():
            raise TypeError()

        self.assertFalse(RaisesMatcher(ValueError).matches(closure))
コード例 #7
0
    def test_should_match_callable_raising_expected_exception(self):
        def closure():
            raise ValueError()

        self.assertTrue(RaisesMatcher(ValueError).matches(closure))
コード例 #8
0
    def test_should_not_accept_object_without_call_function(self):
        class NotCallable:
            pass

        self.assertFalse(RaisesMatcher(BaseException).accepts(NotCallable()))
コード例 #9
0
    def test_should_accept_object_with_call_function(self):
        class Callable:
            def __call__(self):
                pass

        self.assertTrue(RaisesMatcher(BaseException).accepts(Callable()))
コード例 #10
0
    def test_should_accept_function(self):
        def fun():
            pass

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