def assert_file_contents_equal(a, b):
'''
Assert that two files have the same size and hash.
'''
def generate_error_message(a, b):
'''
This creates the error message for the assertion error
'''
size_a = os.stat(a).st_size
size_b = os.stat(b).st_size
if size_a == size_b:
return "Files have the same size but different contents"
else:
return "Files have different sizes: a:%d b: %d" % (size_a, size_b)
assert file_digest(a) == file_digest(b), generate_error_message(a, b)
评论列表
文章目录