def assert_equal(first, second, prefix): # A better assert equals. It allows you to just provide # prefix instead of the entire message. try: _assert_equal(first, second) except Exception: try: better = "%s (actual != expected)\n%s !=\n%s" % ( prefix, json.dumps(first, indent=2), json.dumps(second, indent=2)) except (ValueError, TypeError): better = "%s (actual != expected)\n%s !=\n%s" % (prefix, first, second) raise AssertionError(better)
def assert_equal(first, second, prefix): # A better assert equals. It allows you to just provide # prefix instead of the entire message. try: _assert_equal(first, second) except Exception: try: better = "%s (actual != expected)\n%s !=\n%s" % ( prefix, json.dumps(first, indent=2), json.dumps(second, indent=2)) except (ValueError, TypeError): better = "%s (actual != expected)\n%s !=\n%s" % ( prefix, first, second) raise AssertionError(better)