Skip to content

Instantly share code, notes, and snippets.

@lovemyliwu
Created December 3, 2015 02:52
Show Gist options
  • Save lovemyliwu/e8d8e795c4926582ec47 to your computer and use it in GitHub Desktop.
Save lovemyliwu/e8d8e795c4926582ec47 to your computer and use it in GitHub Desktop.
def assertDictLoop(expected, test_data):
self.assertListEqual(sorted(expected.keys()), sorted(test_data.keys()))
for key in expected.keys():
expected_value = expected[key]
test_value = test_data[key]
if type(expected_value) == dict:
assertDictLoop(expected_value, test_value)
elif type(expected_value) == list:
self.assertListEqual(sorted(expected_value), sorted(test_value))
else:
self.assertEqual(expected_value, test_value,
'%s not equal to %s the key is: %s' % (str(expected_value), str(test_value), key)
)
assertDictLoop(expected, test_data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment