def test_newick_to_tree_node_convert_underscores(self): fh = StringIO('(_:0.1, _a, _b)__;') tree = _newick_to_tree_node(fh, convert_underscores=False) fh2 = StringIO() _tree_node_to_newick(tree, fh2) self.assertEquals(fh2.getvalue(), "('_':0.1,'_a','_b')'__';\n") fh2.close() fh.close()
def test_tree_node_to_newick(self): for tree, newicks in self.trees_newick_lists: newick = newicks[0] fh = StringIO() _tree_node_to_newick(tree, fh) self.assertEqual(newick, fh.getvalue()) fh.close()
def test_roundtrip(self): for tree, newicks in self.trees_newick_lists: newick = newicks[0] fh = StringIO(newick) tree = _newick_to_tree_node(fh) fh2 = StringIO() _tree_node_to_newick(tree, fh2) fh2.seek(0) tree2 = _newick_to_tree_node(fh2) self.assertEqual(newick, fh2.getvalue()) self._assert_equal(tree, tree2) fh.close() fh2.close()