linked_list_test.py tests whether the solution raises the right exceptions with the right error message like this:
def test_can_return_with_pop_and_then_raise_an_error_if_empty(self):
lst = LinkedList()
lst.push(1)
lst.unshift(5)
self.assertEqual(lst.pop(), 1)
self.assertEqual(lst.pop(), 5)
with self.assertRaises(IndexError) as err:
lst.pop()
self.assertEqual(type(err.exception), IndexError)
self.assertEqual(err.exception.args[0], "List is empty")
But the last two lines are inside the with self.assertRaises... block, so they only get executed when lst.pop() does not raise an exception.
I think they should be outside of the block (i.e. the indentation of these two lines should be reduced) so they get executed after an exception has been raised.
That’s how the example in the official documentation does it, and how this answer on StackOverflow explains it.
The same applies to the other test functions that test the error handling.
If it helps I could create a PR but I’m fine if somebody else does it.