def compare_file(reference, this_test):
ref_lines = open(reference,'r').readlines()
ref_lines = [ x.rstrip() for x in ref_lines]
this_test = [ x.rstrip() for x in this_test]
for line in difflib.unified_diff(ref_lines, this_test,
fromfile=reference, tofile="current"):
sys.stdout.write(line.rstrip()+'\n')
if len(ref_lines) != len(this_test):
mbuild.msgb("DIFFERENT NUMBER OF LINES", "ref %d test %d" % (len(ref_lines),len(this_test)))
for ref in ref_lines:
mbuild.msgb("EXPECTED",'%s' % (ref.strip()))
return False
for (ref,test) in zip(ref_lines,this_test):
if ref.strip() != test.strip():
if ref.find("XED version") != -1: # skip the version lines
continue
mbuild.msgb("DIFFERENT", "\n\tref [%s]\n\ttest [%s]" % (ref, test))
return False
return True
评论列表
文章目录