expected = {}
for key in list(input_dict.keys()):
    self.assertIn(key, set(response.data.keys()))
expected[key] = response.data[key]
self.assertDictEqual(input_dict, expected)
How to assert a dict contains another dict without assertDictContainsSubset in python?