From d466d5d66a813ee62f8407dc35aea043a60b706b Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Tue, 27 Dec 2022 10:26:55 +0100 Subject: [PATCH] test/objectstore: use os.stat instead Path.stat Instead of using `Path.stat` use `os.stat` since the former only gained the `follow_symlinks` argument in 3.10 but we still need to support Python 3.6 for RHEL 7 and 8. Additionally, reduce the precision by converting timestamps to an integer to avoid false negatives due to floating point arithmetic. --- test/mod/test_objectstore.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/mod/test_objectstore.py b/test/mod/test_objectstore.py index 01e13d52..9caf9e2f 100644 --- a/test/mod/test_objectstore.py +++ b/test/mod/test_objectstore.py @@ -217,16 +217,16 @@ def test_source_epoch(object_store): l.symlink_to(d, target_is_directory=True) for i in (a, d, l, t): - si = i.stat(follow_symlinks=False) - before = si.st_mtime + si = os.stat(i, follow_symlinks=False) + before = int(si.st_mtime) assert before != tree.source_epoch # FINALIZING tree.finalize() for i in (a, d, l, t): - si = i.stat(follow_symlinks=False) - after = si.st_mtime + si = os.stat(i, follow_symlinks=False) + after = int(si.st_mtime) assert after != before, f"mtime not changed for {i}" assert after == tree.source_epoch @@ -239,15 +239,15 @@ def test_source_epoch(object_store): b = Path(tree, "B") b.touch() - si = b.stat(follow_symlinks=False) - before = si.st_mtime + si = os.stat(b, follow_symlinks=False) + before = int(si.st_mtime) assert before != tree.source_epoch # FINALIZING baum.finalize() - si = a.stat(follow_symlinks=False) - after = si.st_mtime + si = os.stat(a, follow_symlinks=False) + after = int(si.st_mtime) assert after != before assert after == tree.source_epoch