Skip to content

Commit 462a393

Browse files
committed
Fixes failing tests
1 parent 6a71ef3 commit 462a393

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

data_structures/binary_tree/binary_search_tree.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def insert(self, *values):
7676

7777
def search(self, value):
7878
if self.empty():
79-
raise IndexError("Warning: Tree is empty! please use another. ")
79+
raise IndexError("Warning: Tree is empty! please use another.")
8080
else:
8181
node = self.root
8282
# use lazy evaluation here to avoid NoneType Attribute error
@@ -153,7 +153,7 @@ def postorder(curr_node):
153153

154154

155155
def binary_search_tree():
156-
r"""
156+
"""
157157
Example
158158
8
159159
/ \
@@ -163,15 +163,15 @@ def binary_search_tree():
163163
/ \ /
164164
4 7 13
165165
166-
>>> t = BinarySearchTree().insert(8, 3, 6, 1, 10, 14, 13, 4, 7)
167-
>>> print(" ".join(repr(i.value) for i in t.traversal_tree()))
168-
8 3 1 6 4 7 10 14 13
169-
>>> print(" ".join(repr(i.value) for i in t.traversal_tree(postorder)))
170-
1 4 7 6 3 13 14 10 8
171-
>>> BinarySearchTree().search(6)
172-
Traceback (most recent call last):
173-
...
174-
IndexError: Warning: Tree is empty! please use another.
166+
>>> t = BinarySearchTree().insert(8, 3, 6, 1, 10, 14, 13, 4, 7)
167+
>>> print(" ".join(repr(i.value) for i in t.traversal_tree()))
168+
8 3 1 6 4 7 10 14 13
169+
>>> print(" ".join(repr(i.value) for i in t.traversal_tree(postorder)))
170+
1 4 7 6 3 13 14 10 8
171+
>>> BinarySearchTree().search(6)
172+
Traceback (most recent call last):
173+
...
174+
IndexError: Warning: Tree is empty! please use another.
175175
"""
176176
testlist = (8, 3, 6, 1, 10, 14, 13, 4, 7)
177177
t = BinarySearchTree()
@@ -204,4 +204,4 @@ def binary_search_tree():
204204
import doctest
205205

206206
doctest.testmod()
207-
binary_search_tree()
207+
# binary_search_tree()

0 commit comments

Comments
 (0)