Exemplo n.º 1
0
def test_raises_exception_multiple_classes():
    possible_exception_types = (CustomException, OtherException)
    for x in possible_exception_types:
        with should.raise_exception(possible_exception_types):
            raise x()

    with pytest.raises(ExpectedExceptionNotCaught):
        with should.raise_exception((CustomException, )):
            pass
Exemplo n.º 2
0
    def test_raises_exception_multiple_classes(self):
        possible_exception_types = (CustomException, OtherException)
        for x in possible_exception_types:
            with should.raise_exception(possible_exception_types):
                raise x()

        with self.assertRaises(TestFailed) as caught:
            with should.raise_exception((CustomException, )) as caught:
                pass
Exemplo n.º 3
0
def test_raises_exception_multiple_classes():
    possible_exception_types = (CustomException, OtherException)
    for x in possible_exception_types:
        with should.raise_exception(possible_exception_types):
            raise x()

    with pytest.raises(TestFailed):
        with should.raise_exception((CustomException, )):
            pass
Exemplo n.º 4
0
    def test_raises_exception_multiple_classes(self):
        possible_exception_types = (CustomException, OtherException)
        for x in possible_exception_types:
            with should.raise_exception(possible_exception_types):
                raise x()

        with self.assertRaises(TestFailed) as caught:
            with should.raise_exception((CustomException,)) as caught:
                pass
Exemplo n.º 5
0
 def test_raises_exception(self):
     thrown = CustomException()
     with should.raise_exception(CustomException) as caught:
         raise thrown
     self.assertIs(caught.exception, thrown)
     try:
         with should.raise_exception(CustomException):
             raise OtherException()
     except OtherException:
         pass
     else:
         self.fail("should.raise_exception allowed a different type of exception to be raised")
     try:
         with should.raise_exception(CustomException):
             pass
     except TestFailed as e:
         self.assertIn(" not raised", str(e))
     else:
         self.fail("should.raise_exception allowed success")
Exemplo n.º 6
0
 def test_raises_exception(self):
     thrown = CustomException()
     with should.raise_exception(CustomException) as caught:
         raise thrown
     self.assertIs(caught.exception, thrown)
     try:
         with should.raise_exception(CustomException):
             raise OtherException()
     except OtherException:
         pass
     else:
         self.fail(
             "should.raise_exception allowed a different type of exception to be raised"
         )
     try:
         with should.raise_exception(CustomException):
             pass
     except TestFailed as e:
         self.assertIn(" not raised", str(e))
     else:
         self.fail("should.raise_exception allowed success")