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

Function test_node_init_and_setattr_error_cases

tests/test_tree.py:221–250  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

219
220
221def test_node_init_and_setattr_error_cases() -> None:
222 root, left_child, right_child = Node(1), Node(2), Node(3)
223 root.left = left_child
224 root.right = right_child
225
226 with pytest.raises(NodeValueError) as err1:
227 Node(EMPTY_LIST)
228 assert str(err1.value) == "node value must be a float/int/str"
229
230 with pytest.raises(NodeValueError) as err2:
231 Node(1).val = EMPTY_LIST
232 assert str(err2.value) == "node value must be a float/int/str"
233
234 with pytest.raises(NodeTypeError) as err3:
235 Node(1, "this_is_not_a_node") # type: ignore
236 assert str(err3.value) == "left child must be a Node instance"
237
238 with pytest.raises(NodeTypeError) as err4:
239 Node(1, Node(1), "this_is_not_a_node") # type: ignore
240 assert str(err4.value) == "right child must be a Node instance"
241
242 with pytest.raises(NodeTypeError) as err5:
243 root.left = "this_is_not_a_node" # type: ignore
244 assert root.left is left_child
245 assert str(err5.value) == "left child must be a Node instance"
246
247 with pytest.raises(NodeTypeError) as err6:
248 root.right = "this_is_not_a_node" # type: ignore
249 assert root.right is right_child
250 assert str(err6.value) == "right child must be a Node instance"
251
252
253def test_tree_equals_with_integers() -> None:

Callers

nothing calls this directly

Calls 1

NodeClass · 0.90

Tested by

no test coverage detected