Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_Node():
with pytest.raises(ValueError):
Node(name='A)')
root = loads('(A,B,(C,D)E)F;')[0]
assert [n.name for n in root.walk()] == ['F', 'A', 'B', 'E', 'C', 'D']
assert [n.name for n in root.walk() if n.is_leaf] == ['A', 'B', 'C', 'D']
assert [n.name for n in root.walk(mode='postorder')] == ['A', 'B', 'C', 'D', 'E', 'F']
assert root.ancestor is None
assert root.descendants[0].ancestor == root
root = loads('(((a,b),(c,d)),e);')[0]
assert [n.ancestor.newick for n in root.walk() if n.ancestor] == \
[
'(((a,b),(c,d)),e)',
'((a,b),(c,d))',
'(a,b)',
'(a,b)',
'((a,b),(c,d))',
'(c,d)',
def setUp(self):
self.test_obj = Node("A", "1.0")
self.test_descendant = Node("D", "2.0")
self.lengths = ["2.0", "3.0", "4.0"]
def test_node_parameters_changeability(self):
test_obj = Node(name="A")
self.assertEqual("A", test_obj.name)
test_obj.name = "B"
self.assertEqual("B", test_obj.name)
def test_node_newick_representation_without_length(self):
test_obj = Node(name="A")
self.assertEqual("A", test_obj.newick)
def test_repr():
n = Node(name="A")
assert repr(n) == 'Node("A")'
def node():
return Node()
def clone_node(n):
c = Node(name=n.name)
for nn in n.descendants:
c.add_descendant(clone_node(nn))
return c
def setUp(self):
self.test_obj = Node("A", "1.0")
self.test_descendant = Node("D", "2.0")
self.lengths = ["2.0", "3.0", "4.0"]
def test_node_newick_representation_with_length(self):
test_obj = Node(name="A", length="3")
self.assertEqual("A:3", test_obj.newick)