summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_tarfile.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-10-29 10:59:08 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-10-29 10:59:08 (GMT)
commit26bfb5ab82dbba8d771ffc47005865682039f7a8 (patch)
treed760b7340d3e61d153b39cf09525aeeab9daf03a /Lib/test/test_tarfile.py
parente033e06db077d5abcb4bc3729d03f8a4a09b2486 (diff)
downloadcpython-26bfb5ab82dbba8d771ffc47005865682039f7a8.zip
cpython-26bfb5ab82dbba8d771ffc47005865682039f7a8.tar.gz
cpython-26bfb5ab82dbba8d771ffc47005865682039f7a8.tar.bz2
test_tarfile: dump mtime as hexadecimal on test_extractall failure
Diffstat (limited to 'Lib/test/test_tarfile.py')
-rw-r--r--Lib/test/test_tarfile.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py
index 8dc3ff9..7a0d677 100644
--- a/Lib/test/test_tarfile.py
+++ b/Lib/test/test_tarfile.py
@@ -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()