MCPcopy
hub / github.com/joowani/binarytree / test_node_init_and_setattr_with_letters

Function test_node_init_and_setattr_with_letters

tests/test_tree.py:177–218  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

175
176
177def test_node_init_and_setattr_with_letters() -> None:
178 root = Node("A")
179 assert root.left is None
180 assert root.right is None
181 assert root.val == "A"
182 assert root.value == "A"
183 assert repr(root) == "Node(A)"
184
185 root.value = "B"
186 assert root.value == "B"
187 assert root.val == "B"
188 assert repr(root) == "Node(B)"
189
190 root.val = "A"
191 assert root.value == "A"
192 assert root.val == "A"
193 assert repr(root) == "Node(A)"
194
195 left_child = Node("B")
196 root.left = left_child
197 assert root.left is left_child
198 assert root.right is None
199 assert root.val == "A"
200 assert root.left.left is None
201 assert root.left.right is None
202 assert root.left.val == "B"
203 assert repr(left_child) == "Node(B)"
204
205 right_child = Node("C")
206 root.right = right_child
207 assert root.left is left_child
208 assert root.right is right_child
209 assert root.val == "A"
210 assert root.right.left is None
211 assert root.right.right is None
212 assert root.right.val == "C"
213 assert repr(right_child) == "Node(C)"
214
215 last_node = Node("D")
216 left_child.right = last_node
217 assert root.left.right is last_node
218 assert repr(root.left.right) == "Node(D)"
219
220
221def test_node_init_and_setattr_error_cases() -> None:

Callers

nothing calls this directly

Calls 1

NodeClass · 0.90

Tested by

no test coverage detected