Backdate mtime past the racily-clean window so the stat fastpath is allowed to serve this file. A just-written file is deliberately never trusted: its mtime tick may still be open, so a same-length rewrite could hide behind an identical (size, mtime_ns). See cache._stat_sig_fresh. A
(path: Path)
| 11 | |
| 12 | |
| 13 | def _settle(path: Path) -> None: |
| 14 | """Backdate mtime past the racily-clean window so the stat fastpath is |
| 15 | allowed to serve this file. |
| 16 | |
| 17 | A just-written file is deliberately never trusted: its mtime tick may still |
| 18 | be open, so a same-length rewrite could hide behind an identical |
| 19 | (size, mtime_ns). See cache._stat_sig_fresh. Any test asserting a warm stat |
| 20 | hit therefore has to settle the file first. |
| 21 | """ |
| 22 | old = path.stat().st_mtime_ns - 10 * 1_000_000_000 |
| 23 | os.utime(path, ns=(old, old)) |
| 24 | |
| 25 | |
| 26 | def test_word_count_cached_until_file_changes(tmp_path, monkeypatch): |
no outgoing calls
no test coverage detected