def testCatchIgnoresOthers(self): """Does catch ignore other exceptions thrown within the tree? """ tree = owyl.sequence( owyl.succeed(), owyl.succeed(), owyl.catch(owyl.throw(throws=ValueError, throws_message="AUGH!!"), caught=IndexError, branch=owyl.succeed())) v = owyl.visit(tree) self.assertEqual(v.next(), True) self.assertEqual(v.next(), True) self.assertRaises(ValueError, v.next) v = owyl.visit(tree) self.assertEqual(v.next(), True) self.assertEqual(v.next(), True) self.assertRaises(ValueError, v.next)
def testCatch(self): """Can we catch an exception thrown within the tree? """ tree = owyl.sequence( owyl.succeed(), owyl.succeed(), owyl.catch(owyl.throw(throws=ValueError, throws_message="AUGH!!"), caught=ValueError, branch=owyl.succeed())) v = owyl.visit(tree) self.assertEqual(v.next(), True) self.assertEqual(v.next(), True) self.assertEqual(v.next(), True) v = owyl.visit(tree) self.assertEqual(v.next(), True) self.assertEqual(v.next(), True) self.assertEqual(v.next(), True)
def testCatchIgnoresOthers(self): """Does catch ignore other exceptions thrown within the tree? """ tree = owyl.sequence(owyl.succeed(), owyl.succeed(), owyl.catch(owyl.throw(throws=ValueError, throws_message="AUGH!!"), caught=IndexError, branch=owyl.succeed()) ) v = owyl.visit(tree) self.assertEqual(v.next(), True) self.assertEqual(v.next(), True) self.assertRaises(ValueError, v.next) v = owyl.visit(tree) self.assertEqual(v.next(), True) self.assertEqual(v.next(), True) self.assertRaises(ValueError, v.next)
def testCatch(self): """Can we catch an exception thrown within the tree? """ tree = owyl.sequence(owyl.succeed(), owyl.succeed(), owyl.catch(owyl.throw(throws=ValueError, throws_message="AUGH!!"), caught=ValueError, branch=owyl.succeed()) ) v = owyl.visit(tree) self.assertEqual(v.next(), True) self.assertEqual(v.next(), True) self.assertEqual(v.next(), True) v = owyl.visit(tree) self.assertEqual(v.next(), True) self.assertEqual(v.next(), True) self.assertEqual(v.next(), True)