def test_stepping_backward(self): tree = self.basic_tree node = tree.root for name in (str(i).zfill(2) for i in range(10, 0, -1)): # 10 ... 01 (inclusive) node = step(tree, node, dir='back') self.assertEqual(node.name, name) self.assertTrue(step(tree, node, dir='back') is None)
def test_stepping_forward(self): tree = self.basic_tree node = tree.root for name in (str(i).zfill(2) for i in range(1, 11)): # 01 ... 10 (inclusive) node = step(tree, node) self.assertEqual(node.name, name) self.assertTrue(step(tree, node) is None)
def get_prev_next(tree, node, steps, dir='next'): result = [] node = step(tree, node, dir) for i in range(steps): if node is None: break result.append(node) node = step(tree, node, dir) return result