I wasn't sure how to create a Python unittest to check if a dictionary returned a KeyError. I thought the unit test would call the dictionary key so it would look like this:
def test_dict_keyerror_should_appear(self):
my_dict = {'hey': 'world'}
self.assertRaises(KeyError, my_dict['some_key'])
However, my test would just error out with a KeyError instead of asserting that a KeyError occurred.