def test_repr(self): obj = CubeStack() # no repr tree_str = obj.tree_str(name='cubestack', add_repr=False) for line in tree_str.rstrip('\n').split('\n'): self.assertIsNone(re.search(r'<[^>]+>', line)) # repr on each line tree_str = obj.tree_str(name='cubestack', add_repr=True) for line in tree_str.rstrip('\n').split('\n'): self.assertIsNotNone(re.search(r'<[^>]+>', line)) # repeat: nested obj obj = SimpleCar() tree_str = obj.tree_str(name='car', add_repr=True) for line in tree_str.rstrip('\n').split('\n'): self.assertIsNotNone(re.search(r'<[^>]+>', line))
def test_prefix(self): obj = CubeStack() tree_str = obj.tree_str(name='cubestack', prefix="--") self.assertEqual( tree_str, '\n'.join([ u"--cubestack", u"-- \u251c\u25cb cube_a", u"-- \u2514\u25cb cube_b\n", ]))
def test_one_layer(self): obj = CubeStack() tree_str = obj.tree_str(name='cubestack') self.assertEqual( tree_str, '\n'.join([ u"cubestack", u" \u251c\u25cb cube_a", u" \u2514\u25cb cube_b\n", ]))