MCPcopy
hub / github.com/pydata/xarray / test_relative_paths

Method test_relative_paths

xarray/tests/test_datatree.py:172–191  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

170 assert mary.same_tree(kate)
171
172 def test_relative_paths(self) -> None:
173 john = DataTree.from_dict(
174 {
175 "/Mary/Sue": DataTree(),
176 "/Annie": DataTree(),
177 }
178 )
179 sue = john.children["Mary"].children["Sue"]
180 annie = john.children["Annie"]
181 assert sue.relative_to(john) == "Mary/Sue"
182 assert john.relative_to(sue) == "../.."
183 assert annie.relative_to(sue) == "../../Annie"
184 assert sue.relative_to(annie) == "../Mary/Sue"
185 assert sue.relative_to(sue) == "."
186
187 evil_kate = DataTree()
188 with pytest.raises(
189 NotFoundInTreeError, match="nodes do not lie within the same tree"
190 ):
191 sue.relative_to(evil_kate)
192
193
194class TestStoreDatasets:

Callers

nothing calls this directly

Calls 3

DataTreeClass · 0.90
relative_toMethod · 0.80
from_dictMethod · 0.45

Tested by

no test coverage detected