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

Method test_create_intermediate_child

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

Source from the content-addressed store, hash-verified

226 assert rose.parent is mary
227
228 def test_create_intermediate_child(self) -> None:
229 john: TreeNode = TreeNode()
230 rose: TreeNode = TreeNode()
231
232 # test intermediate children not allowed
233 with pytest.raises(KeyError, match="Could not reach"):
234 john._set_item(path="Mary/Rose", item=rose, new_nodes_along_path=False)
235
236 # test intermediate children allowed
237 john._set_item("Mary/Rose", rose, new_nodes_along_path=True)
238 assert "Mary" in john.children
239 mary = john.children["Mary"]
240 assert isinstance(mary, TreeNode)
241 assert mary.children == {"Rose": rose}
242 assert rose.parent == mary
243 assert rose.parent == mary
244
245 def test_overwrite_child(self) -> None:
246 john: TreeNode = TreeNode()

Callers

nothing calls this directly

Calls 2

_set_itemMethod · 0.95
TreeNodeClass · 0.90

Tested by

no test coverage detected