MCPcopy Index your code
hub / github.com/pydata/xarray / test_render_nodetree

Method test_render_nodetree

xarray/tests/test_treenode.py:481–506  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

479
480class TestRenderTree:
481 def test_render_nodetree(self) -> None:
482 john: NamedNode = NamedNode(
483 children={
484 "Mary": NamedNode(children={"Sam": NamedNode(), "Ben": NamedNode()}),
485 "Kate": NamedNode(),
486 }
487 )
488 mary = john.children["Mary"]
489
490 expected_nodes = [
491 "NamedNode()",
492 "\tNamedNode('Mary')",
493 "\t\tNamedNode('Sam')",
494 "\t\tNamedNode('Ben')",
495 "\tNamedNode('Kate')",
496 ]
497 expected_str = "NamedNode('Mary')"
498 john_repr = john.__repr__()
499 mary_str = mary.__str__()
500
501 assert mary_str == expected_str
502
503 john_nodes = john_repr.splitlines()
504 assert len(john_nodes) == len(expected_nodes)
505 for expected_node, repr_node in zip(expected_nodes, john_nodes, strict=True):
506 assert expected_node == repr_node
507
508
509def test_nodepath():

Callers

nothing calls this directly

Calls 3

__repr__Method · 0.95
NamedNodeClass · 0.90
__str__Method · 0.45

Tested by

no test coverage detected