Esempio n. 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")
Esempio n. 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")
Esempio n. 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")
Esempio n. 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")
Esempio n. 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")
Esempio n. 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")
Esempio n. 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")
Esempio n. 8
0
 def test_assert_falsey_with_msg(self):
     with assertions.assert_raises_exactly(AssertionError, 'my_msg'):
         assert_falsey(1, message='my_msg')
Esempio n. 9
0
 def test_assert_truthy_with_msg(self):
     with assertions.assert_raises_exactly(AssertionError, 'my_msg'):
         assert_truthy(0, message='my_msg')
Esempio n. 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")
Esempio n. 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")
Esempio n. 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")
Esempio n. 13
0
 def test_assert_falsey_with_msg(self):
     with assertions.assert_raises_exactly(AssertionError, 'my_msg'):
         assert_falsey(1, message='my_msg')
Esempio n. 14
0
 def test_assert_truthy_with_msg(self):
     with assertions.assert_raises_exactly(AssertionError, 'my_msg'):
         assert_truthy(0, message='my_msg')