commit:     03441262d4362f83fa8bbcbfd6e6960b16f891fe
Author:     Brian Harring <ferringb <AT> gmail <DOT> com>
AuthorDate: Mon Nov 24 21:43:56 2025 +0000
Commit:     Brian Harring <ferringb <AT> gmail <DOT> com>
CommitDate: Mon Nov 24 23:02:36 2025 +0000
URL:        
https://gitweb.gentoo.org/proj/pkgcore/snakeoil.git/commit/?id=03441262

fix: tests against FS's lacking NS precision

Modern realtime/etc also means "this exact NS" can be fuzzy.  The best we
can do is assert that we're telling python's API to set the NS- if they do, they
do.  If they don't, there's nothing we can do if the underlying FS isn't NS 
capable.

Closes: pkgcore/snakeoil#53

Signed-off-by: Brian Harring <ferringb <AT> gmail.com>

 tests/test_fileutils.py | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)

diff --git a/tests/test_fileutils.py b/tests/test_fileutils.py
index f339b9b..0db7ce2 100644
--- a/tests/test_fileutils.py
+++ b/tests/test_fileutils.py
@@ -3,10 +3,12 @@ import gc
 import mmap
 import os
 import time
+from unittest import mock
 
 pjoin = os.path.join
 
 import pytest
+
 from snakeoil import _fileutils, currying, fileutils
 from snakeoil.fileutils import AtomicWriteFile
 from snakeoil.test import random_str
@@ -47,21 +49,11 @@ class TestTouch:
         assert 1 == new_stat.st_mtime
 
     def test_set_custom_nstimes(self, random_path):
-        fileutils.touch(random_path)
-        orig_stat = random_path.stat()
-        ns = (1, 1)
-        fileutils.touch(random_path, ns=ns)
-        new_stat = random_path.stat()
-
-        # system doesn't have nanosecond precision, try microseconds
-        if new_stat.st_atime == 0:
-            ns = (1000, 1000)
-            fileutils.touch(random_path, ns=ns)
-            new_stat = random_path.stat()
-
-        assert orig_stat != new_stat
-        assert ns[0] == new_stat.st_atime_ns
-        assert ns[0] == new_stat.st_mtime_ns
+        # just assert it can take the ns argument, even if it the underlying 
FS has that precession.
+        # other tests confirm the execution, this is literally just ns.
+        with mock.patch("os.utime") as f:
+            fileutils.touch(random_path, ns=(1, 1))
+            f.assert_called_with(random_path, dir_fd=None, ns=(1, 1))
 
 
 class TestAtomicWriteFile:

Reply via email to