From f496497d920bc4fa2818989e1b413fc5a1f6ae5c Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Mon, 2 Mar 2026 23:03:44 +0100 Subject: [PATCH] time calculations: avoid floating point Do not use 1e9 if it is not mean to be a fp calculation anyway, but rather use 10**9 for pure integer calculations. --- src/borg/testsuite/archiver/create_cmd_test.py | 2 +- src/borg/testsuite/archiver/extract_cmd_test.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/borg/testsuite/archiver/create_cmd_test.py b/src/borg/testsuite/archiver/create_cmd_test.py index 00edc0935..f99b187a6 100644 --- a/src/borg/testsuite/archiver/create_cmd_test.py +++ b/src/borg/testsuite/archiver/create_cmd_test.py @@ -223,7 +223,7 @@ def test_nobirthtime(archivers, request): assert same_ts_ns(sti.st_birthtime * 1e9, birthtime * 1e9) assert same_ts_ns(sto.st_birthtime * 1e9, mtime * 1e9) assert same_ts_ns(sti.st_mtime_ns, sto.st_mtime_ns) - assert same_ts_ns(sto.st_mtime_ns, mtime * 1e9) + assert same_ts_ns(sto.st_mtime_ns, mtime * 10**9) def test_create_stdin(archivers, request): diff --git a/src/borg/testsuite/archiver/extract_cmd_test.py b/src/borg/testsuite/archiver/extract_cmd_test.py index fe41c23a0..db131a5a0 100644 --- a/src/borg/testsuite/archiver/extract_cmd_test.py +++ b/src/borg/testsuite/archiver/extract_cmd_test.py @@ -153,13 +153,13 @@ def test_atime(archivers, request): sti = os.stat("input/file1") sto = os.stat("output/input/file1") assert same_ts_ns(sti.st_mtime_ns, sto.st_mtime_ns) - assert same_ts_ns(sto.st_mtime_ns, mtime * 1e9) + assert same_ts_ns(sto.st_mtime_ns, mtime * 10**9) if have_noatime: assert same_ts_ns(sti.st_atime_ns, sto.st_atime_ns) - assert same_ts_ns(sto.st_atime_ns, atime * 1e9) + assert same_ts_ns(sto.st_atime_ns, atime * 10**9) else: # it touched the input file's atime while backing it up - assert same_ts_ns(sto.st_atime_ns, atime * 1e9) + assert same_ts_ns(sto.st_atime_ns, atime * 10**9) @pytest.mark.skipif(not is_utime_fully_supported(), reason="cannot setup and execute test without utime") @@ -179,7 +179,7 @@ def test_birthtime(archivers, request): assert same_ts_ns(sti.st_birthtime * 1e9, sto.st_birthtime * 1e9) assert same_ts_ns(sto.st_birthtime * 1e9, birthtime * 1e9) assert same_ts_ns(sti.st_mtime_ns, sto.st_mtime_ns) - assert same_ts_ns(sto.st_mtime_ns, mtime * 1e9) + assert same_ts_ns(sto.st_mtime_ns, mtime * 10**9) @pytest.mark.skipif(is_win32, reason="frequent test failures on github CI on win32")