def test_set_unchecked_should_correctly_set_and_unset_unchecked_exceptions( self): from operator import getitem Try_.set_unhandled([IndexError]) self.assertRaises(IndexError, Try, getitem, [1], 3) Try_.set_unhandled() self.assertTrue(Try(getitem, [1], 3).isFailure)
def test__try_identity_if_try_or_raise(self): success = Success(1) failure = Failure(Exception("e")) self.assertRaises(TypeError, Try_._identity_if_try_or_raise, 1) self.assertEqual(Try_._identity_if_try_or_raise(success), success) self.assertEqual(Try_._identity_if_try_or_raise(failure), failure)
def test__try_raise_if_not_exception(self): self.assertRaises(TypeError, Try_._raise_if_not_exception, 1) self.assertTrue(Try_._raise_if_not_exception(Exception("e")))