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
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
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
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
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")
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")