Example #1
0
    def test_unexpected_exception_passes_through(self):
        class DifferentException(Exception):
            pass

        with assertions.assert_raises(DifferentException):
            with assertions.assert_raises_exactly(self.MyException, "first", "second"):
                raise DifferentException("first", "second")
Example #2
0
    def test_fails_with_different_class(self):
        class SpecialException(self.MyException):
            pass

        with assertions.assert_raises(AssertionError):
            with assertions.assert_raises_exactly(self.MyException, "first", "second"):
                raise SpecialException("first", "second")
Example #3
0
    def test_unexpected_exception_passes_through(self):
        class DifferentException(Exception):
            pass

        with assertions.assert_raises(DifferentException):
            with assertions.assert_raises_exactly(self.MyException, "first",
                                                  "second"):
                raise DifferentException("first", "second")
Example #4
0
    def test_fails_with_different_class(self):
        class SpecialException(self.MyException):
            pass

        with assertions.assert_raises(AssertionError):
            with assertions.assert_raises_exactly(self.MyException, "first",
                                                  "second"):
                raise SpecialException("first", "second")
Example #5
0
 def test_fails_with_vague_class(self):
     with assertions.assert_raises(AssertionError):
         with assertions.assert_raises_exactly(Exception, "first",
                                               "second"):
             raise self.MyException("first", "second")
Example #6
0
 def test_fails_with_wrong_value(self):
     with assertions.assert_raises(AssertionError):
         with assertions.assert_raises_exactly(self.MyException, "first",
                                               "second"):
             raise self.MyException("red", "blue")
Example #7
0
 def test_passes_when_correct_exception_is_raised(self):
     with assertions.assert_raises_exactly(self.MyException, "first",
                                           "second"):
         raise self.MyException("first", "second")
Example #8
0
 def test_assert_falsey_with_msg(self):
     with assertions.assert_raises_exactly(AssertionError, 'my_msg'):
         assert_falsey(1, message='my_msg')
Example #9
0
 def test_assert_truthy_with_msg(self):
     with assertions.assert_raises_exactly(AssertionError, 'my_msg'):
         assert_truthy(0, message='my_msg')
Example #10
0
 def test_fails_with_vague_class(self):
     with assertions.assert_raises(AssertionError):
         with assertions.assert_raises_exactly(Exception, "first", "second"):
             raise self.MyException("first", "second")
Example #11
0
 def test_fails_with_wrong_value(self):
     with assertions.assert_raises(AssertionError):
         with assertions.assert_raises_exactly(self.MyException, "first", "second"):
             raise self.MyException("red", "blue")
Example #12
0
 def test_passes_when_correct_exception_is_raised(self):
     with assertions.assert_raises_exactly(self.MyException, "first", "second"):
         raise self.MyException("first", "second")
Example #13
0
 def test_assert_falsey_with_msg(self):
     with assertions.assert_raises_exactly(AssertionError, 'my_msg'):
         assert_falsey(1, message='my_msg')
Example #14
0
 def test_assert_truthy_with_msg(self):
     with assertions.assert_raises_exactly(AssertionError, 'my_msg'):
         assert_truthy(0, message='my_msg')