Created
June 25, 2013 11:08
-
-
Save ei-grad/5857691 to your computer and use it in GitHub Desktop.
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 dictdiff(f): | |
| def wrapper(a, b, *args, **kwargs): | |
| try: | |
| f(a, b, *args, **kwargs) | |
| except AssertionError as e: | |
| if isinstance(a, dict) and isinstance(b, dict): | |
| a_items = a.items() | |
| b_items = b.items() | |
| in_a = [i for i in a_items if i not in b_items] | |
| in_b = [i for i in b_items if i not in a_items] | |
| e.args = tuple(["\nIn first dict: %s\nIn second dict: %s" % ( | |
| in_a, | |
| in_b | |
| )] + list(e.args[1:])) | |
| raise e | |
| return wrapper |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment