def compare(actual, expected): """Compare the s-expresions and return a diff if they are different.""" actual = sexps.sort_decls(sexps.parse_sexp(actual)) expected = sexps.sort_decls(sexps.parse_sexp(expected)) if actual == expected: return None actual = sexps.sexp_to_string(actual) expected = sexps.sexp_to_string(expected) return difflib.unified_diff(expected.splitlines(), actual.splitlines())