Пример #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))