mikeizbicki / cmc-csci046

CMC's Data Structures and Algorithms Course Materials
52 stars 152 forks source link

Error from insert test for containers/BST.py #497

Closed afr13dman closed 1 year ago

afr13dman commented 1 year ago

I'm working on the insert function for containers/BST.py. Right now, when I run:

python3 -m pytest tests/test_BST.py -k insert -x

the first error I get is:

_____________________________ test__BST_insert ______________________________

    @given(xs=ints)
>   def test__BST_insert(xs):

tests/test_BST.py:92: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

xs = [0]

    @given(xs=ints)
    def test__BST_insert(xs):
        xs = list(set(xs))
        bst = BST()
        for x in xs:
            bst.insert(x)
>           assert x in bst.to_list('inorder')
E           AssertionError: assert 0 in []
E            +  where [] = <bound method BinaryTree.to_list of BST([])>('inorder')
E            +    where <bound method BinaryTree.to_list of BST([])> = BST([]).to_list

tests/test_BST.py:97: AssertionError
-------------------------------------- Hypothesis ---------------------------------------
Falsifying example: test__BST_insert(
    xs=[0],
)

I'm a bit confused by what the error message is saying the issue is and where I should look. Should I look at my insert function or my to_list function of the BinaryTree class in containers/Binary_Tree.py? Thanks.