Skip to content

Commit d3629bb

Browse files
committed
change copying behaviour to be in line with pydata#9196
1 parent 9e02ae2 commit d3629bb

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

xarray/tests/test_treenode.py

+16-13
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,21 @@ def test_dont_modify_children_inplace(self):
7171
assert child.parent is None
7272

7373
def test_multi_child_family(self):
74-
mary: TreeNode = TreeNode()
75-
kate: TreeNode = TreeNode()
76-
john: TreeNode = TreeNode(children={"Mary": mary, "Kate": kate})
77-
assert john.children["Mary"] is mary
78-
assert john.children["Kate"] is kate
74+
john: TreeNode = TreeNode(children={"Mary": TreeNode(), "Kate": TreeNode()})
75+
76+
assert "Mary" in john.children
77+
mary = john.children["Mary"]
78+
assert isinstance(mary, TreeNode)
7979
assert mary.parent is john
80+
81+
assert "Kate" in john.children
82+
kate = john.children["Kate"]
83+
assert isinstance(kate, TreeNode)
8084
assert kate.parent is john
8185

8286
def test_disown_child(self):
83-
mary: TreeNode = TreeNode()
84-
john: TreeNode = TreeNode(children={"Mary": mary})
87+
john: TreeNode = TreeNode(children={"Mary": TreeNode()})
88+
mary = john.children["Mary"]
8589
mary.orphan()
8690
assert mary.parent is None
8791
assert "Mary" not in john.children
@@ -102,12 +106,11 @@ def test_doppelganger_child(self):
102106
assert john.children["Kate"] is evil_kate
103107

104108
def test_sibling_relationships(self):
105-
mary: TreeNode = TreeNode()
106-
kate: TreeNode = TreeNode()
107-
ashley: TreeNode = TreeNode()
108-
TreeNode(children={"Mary": mary, "Kate": kate, "Ashley": ashley})
109-
assert kate.siblings["Mary"] is mary
110-
assert kate.siblings["Ashley"] is ashley
109+
john = TreeNode(
110+
children={"Mary": TreeNode(), "Kate": TreeNode(), "Ashley": TreeNode()}
111+
)
112+
kate = john.children["Kate"]
113+
assert list(kate.siblings) == ["Mary", "Ashley"]
111114
assert "Kate" not in kate.siblings
112115

113116
def test_ancestors(self):

0 commit comments

Comments
 (0)