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

Function test_node_init_and_setattr_with_integers

tests/test_tree.py:89–130  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

87
88
89def test_node_init_and_setattr_with_integers() -> None:
90 root = Node(1)
91 assert root.left is None
92 assert root.right is None
93 assert root.val == 1
94 assert root.value == 1
95 assert repr(root) == "Node(1)"
96
97 root.value = 2
98 assert root.value == 2
99 assert root.val == 2
100 assert repr(root) == "Node(2)"
101
102 root.val = 1
103 assert root.value == 1
104 assert root.val == 1
105 assert repr(root) == "Node(1)"
106
107 left_child = Node(2)
108 root.left = left_child
109 assert root.left is left_child
110 assert root.right is None
111 assert root.val == 1
112 assert root.left.left is None
113 assert root.left.right is None
114 assert root.left.val == 2
115 assert repr(left_child) == "Node(2)"
116
117 right_child = Node(3)
118 root.right = right_child
119 assert root.left is left_child
120 assert root.right is right_child
121 assert root.val == 1
122 assert root.right.left is None
123 assert root.right.right is None
124 assert root.right.val == 3
125 assert repr(right_child) == "Node(3)"
126
127 last_node = Node(4)
128 left_child.right = last_node
129 assert root.left.right is last_node
130 assert repr(root.left.right) == "Node(4)"
131
132
133def test_node_init_and_setattr_with_floats() -> None:

Callers

nothing calls this directly

Calls 1

NodeClass · 0.90

Tested by

no test coverage detected