Kaydet (Commit) 12820c0d authored tarafından Antoine Pitrou's avatar Antoine Pitrou

Revert utime(..., None) strategy (it has too poor resolution under Windows) and…

Revert utime(..., None) strategy (it has too poor resolution under Windows) and restore the previous test workaround
(issue #19715)
üst c3055be5
...@@ -6,6 +6,7 @@ import os ...@@ -6,6 +6,7 @@ import os
import posixpath import posixpath
import re import re
import sys import sys
import time
import weakref import weakref
try: try:
import threading import threading
...@@ -1075,8 +1076,9 @@ class Path(PurePath): ...@@ -1075,8 +1076,9 @@ class Path(PurePath):
# First try to bump modification time # First try to bump modification time
# Implementation note: GNU touch uses the UTIME_NOW option of # Implementation note: GNU touch uses the UTIME_NOW option of
# the utimensat() / futimens() functions. # the utimensat() / futimens() functions.
t = time.time()
try: try:
self._accessor.utime(self, None) self._accessor.utime(self, (t, t))
except OSError: except OSError:
# Avoid exception chaining # Avoid exception chaining
pass pass
......
...@@ -1391,8 +1391,11 @@ class _BasePathTest(object): ...@@ -1391,8 +1391,11 @@ class _BasePathTest(object):
# The file mtime should be refreshed by calling touch() again # The file mtime should be refreshed by calling touch() again
p.touch() p.touch()
st = p.stat() st = p.stat()
self.assertGreaterEqual(st.st_mtime_ns, old_mtime_ns) # Issue #19715: there can be an inconsistency under Windows between
self.assertGreaterEqual(st.st_mtime, old_mtime) # 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 # Now with exist_ok=False
p = P / 'newfileB' p = P / 'newfileB'
self.assertFalse(p.exists()) self.assertFalse(p.exists())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment