test_tarfile: dump mtime as hexadecimal on test_extractall failure

This commit is contained in:
Victor Stinner 2010-10-29 10:59:08 +00:00
parent e033e06db0
commit 26bfb5ab82
1 changed files with 11 additions and 1 deletions

View File

@ -345,7 +345,17 @@ class MiscReadTest(CommonReadTest):
if sys.platform != "win32":
# Win32 has no support for fine grained permissions.
self.assertEqual(tarinfo.mode & 0o777, os.stat(path).st_mode & 0o777)
self.assertEqual(tarinfo.mtime, os.path.getmtime(path))
def format_mtime(mtime):
if isinstance(mtime, float):
return "{} ({})".format(mtime, mtime.hex())
else:
return "{!r} (int)".format(mtime)
file_mtime = os.path.getmtime(path) + 0.001
errmsg = "tar mtime {0} != file time {1} of path {2!a}".format(
format_mtime(tarinfo.mtime),
format_mtime(file_mtime),
path)
self.assertEqual(tarinfo.mtime, file_mtime, errmsg)
finally:
tar.close()