From: Antoine Pitrou Date: Sat, 23 Nov 2013 00:32:53 +0000 (+0100) Subject: Try to fix issue #19715 (timestamp rounding inconsistencies under Windows?) X-Git-Tag: v3.4.0b1~93 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bb6694de85341a0312beba1f91a364b8880008de;p=python Try to fix issue #19715 (timestamp rounding inconsistencies under Windows?) --- 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)