Skip to content

Instantly share code, notes, and snippets.

@snowleung
Last active December 25, 2015 07:12
Show Gist options
  • Save snowleung/d0aa199bb7861f5dc0d9 to your computer and use it in GitHub Desktop.
Save snowleung/d0aa199bb7861f5dc0d9 to your computer and use it in GitHub Desktop.
auto_assert_dict_value
def dict_to_assert(dict_name, d):
template = '''self.assertEqual({}['{}'], {})'''.format(dict_name, '{}', '{}')
for k,v in d.items():
try:
assert_line = template.format(k, v)
except Exception as ex:
assert_line = template.format(k, ex)
print assert_line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment