Last active
December 25, 2015 07:12
-
-
Save snowleung/d0aa199bb7861f5dc0d9 to your computer and use it in GitHub Desktop.
auto_assert_dict_value
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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