gh-161262: Fix test_touch_common flake on Emscripten (#161464) Under Node, NODEFS takes a new file's mtime from the host kernel but utime(path, None) uses Date.now() written back via fs.utimesSync, which can land a millisecond before the creation time. Take the baseline from utime(path, None) too, so both timestamps come from the same source. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
diff --git a/Lib/test/test_pathlib/test_pathlib.py b/Lib/test/test_pathlib/test_pathlib.py index 788547c..10e3ad6 100644 --- a/Lib/test/test_pathlib/test_pathlib.py +++ b/Lib/test/test_pathlib/test_pathlib.py
@@ -2332,6 +2332,9 @@ def test_touch_common(self): self.assertFalse(p.exists()) p.touch() self.assertTrue(p.exists()) + # Take the baseline from utime(None) like touch() below; creation can + # use a different clock (Emscripten NODEFS). + os.utime(p, None) st = p.stat() old_mtime = st.st_mtime old_mtime_ns = st.st_mtime_ns