You've already done a pretty good job adding these tests and covering a big chunk of the code under test.
The problem is, if we look at the branch coverage, we'll see that quite a few of the branches are not reached as the implementation is relatively "complex" - by code complexity standards:
python -m pytest test_tree.py --cov-branch --cov=tree --cov-report html
Using pytest and pytest-cov plugin, tree here is the module/package name for which to measure coverage.
Other observations:
self.assertEquals()is deprecated in favor ofself.assertEqual()- even though
setUpandtearDownare the legacy camel-case Junit-inspired names, consider following PEP8 and naming your methods in an lower_case_with_underscores style - look into defining your tree as a
pytestfixture - look into property-based-testing with Hypothesis as a means to generate possible input nodes for your tree
- focus on the more complex parts first as this is where the possibility of having a problem is higher - the
splay()method should probably be tested separately and directly checking all the major variations of re-balancing the tree when a new node is added