From bb6694de85341a0312beba1f91a364b8880008de Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Sat, 23 Nov 2013 01:32:53 +0100 Subject: [PATCH] Try to fix issue #19715 (timestamp rounding inconsistencies under Windows?) --- Lib/test/test_pathlib.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py index 2aa8af2511..6663ffa283 100755 --- a/Lib/test/test_pathlib.py +++ b/Lib/test/test_pathlib.py @@ -1388,11 +1388,15 @@ class _BasePathTest(object): # Rewind the mtime sufficiently far in the past to work around # filesystem-specific timestamp granularity. os.utime(str(p), (old_mtime - 10, old_mtime - 10)) - # The file mtime is refreshed by calling touch() again + # The file mtime should be refreshed by calling touch() again p.touch() st = p.stat() - self.assertGreaterEqual(st.st_mtime_ns, old_mtime_ns) - self.assertGreaterEqual(st.st_mtime, old_mtime) + # Issue #19715: there can be an inconsistency under Windows between + # the timestamp rounding when creating a file, and the timestamp + # rounding done when calling utime(). `delta` makes up for this. + delta = 1e-6 if os.name == 'nt' else 0 + self.assertGreaterEqual(st.st_mtime, old_mtime - delta) + # Now with exist_ok=False p = P / 'newfileB' self.assertFalse(p.exists()) p.touch(mode=0o700, exist_ok=False) -- 2.40.0