]> granicus.if.org Git - python/commitdiff
Try to fix issue #19715 (timestamp rounding inconsistencies under Windows?)
authorAntoine Pitrou <solipsis@pitrou.net>
Sat, 23 Nov 2013 00:32:53 +0000 (01:32 +0100)
committerAntoine Pitrou <solipsis@pitrou.net>
Sat, 23 Nov 2013 00:32:53 +0000 (01:32 +0100)
Lib/test/test_pathlib.py

index 2aa8af2511b3bf5822c68557243d7b8b2bbd2a58..6663ffa2833e02e420dd1c5eec458df897154b60 100755 (executable)
@@ -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)