Skip to content

Commit 9a58278

Browse files
committed
test: improve mtime simulation for file modification in namespace validation
1 parent c2b6a79 commit 9a58278

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

tests/robotcode/robot/diagnostics/test_namespace_cache.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -340,11 +340,11 @@ def test_source_mtime_changed_fails(self, tmp_path: Path) -> None:
340340

341341
meta = ImportsManager.build_namespace_meta(im, str(source), ns)
342342

343-
# Modify the file → mtime changes
344-
source.write_text("modified content!")
345-
# Ensure mtime differs even on filesystems with coarse resolution (e.g. Windows NTFS)
346-
stat = source.stat()
347-
os.utime(source, ns=(stat.st_atime_ns + 1_000_000_000, stat.st_mtime_ns + 1_000_000_000))
343+
# Simulate a file modification by shifting the stored mtime.
344+
# This is more reliable than writing the file again and hoping
345+
# the filesystem updates the mtime (Windows NTFS has coarse
346+
# resolution and can keep the same mtime for fast writes).
347+
meta.source_mtime_ns -= 1
348348
assert ImportsManager.validate_namespace_meta(im, meta) is False
349349

350350
def test_source_deleted_fails(self, tmp_path: Path) -> None:

0 commit comments

Comments
 (0)