from io import StringIO from contextlib import closing from trace_commentor import flags, Commentor def asserteq_or_print(value, ground_truth): if flags.DEBUG or flags.PRINT: print(value) else: value = value.strip("\n").rstrip(" ") ground_truth = ground_truth.strip("\n").rstrip(" ") assert value == ground_truth, "\n".join(["\n\n<<<<<<<< VALUE", value, "========================", ground_truth, ">>>>>>>> GROUND\n"])