[3.14] gh-102184: Test os.sync() only if the "walltime" resource is enabled (GH-155448) (GH-155462)

serhiy-storchaka <[email protected]> Mon, 10 Aug 2026 03:15:27 -0400 (EDT)
Newsgroups gmane.comp.python.cvs
Message-ID <[email protected]>
https://github.com/python/cpython/commit/b54c346976c4e82f7d90ff52da15f501e02f3f3f
commit: b54c346976c4e82f7d90ff52da15f501e02f3f3f
branch: 3.14
author: Miss Islington (bot) <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2026-08-10T07:14:55Z
summary:

[3.14] gh-102184: Test os.sync() only if the "walltime" resource is enabled (GH-155448) (GH-155462)

Calling sync() flushes all filesystem buffers and can block for a long
time, so it should not run in the default test suite.
(cherry picked from commit e45d4560d11a83022af72dcf7f52a7d2cb704860)

Co-authored-by: Serhiy Storchaka <[email protected]>
Co-authored-by: Alexey Izbyshev <[email protected]>

files:
M Lib/test/test_posix.py

diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py
index cdc80b1dc0d345..03538a940cb363 100644
--- a/Lib/test/test_posix.py
+++ b/Lib/test/test_posix.py
@@ -71,7 +71,7 @@ def testNoArgFunctions(self):
         NO_ARG_FUNCTIONS = [ "ctermid", "getcwd", "getcwdb", "uname",
                              "times", "getloadavg",
                              "getegid", "geteuid", "getgid", "getgroups",
-                             "getpid", "getpgrp", "getppid", "getuid", "sync",
+                             "getpid", "getpgrp", "getppid", "getuid",
                            ]
 
         for name in NO_ARG_FUNCTIONS:
@@ -81,6 +81,13 @@ def testNoArgFunctions(self):
                     posix_func()
                     self.assertRaises(TypeError, posix_func, 1)
 
+    # gh-102184: sync() can block for a long time.
+    @support.requires_resource('walltime')
+    @unittest.skipUnless(hasattr(posix, 'sync'), 'test needs posix.sync()')
+    def test_sync(self):
+        posix.sync()
+        self.assertRaises(TypeError, posix.sync, 1)
+
     @unittest.skipUnless(hasattr(posix, 'getresuid'),
                          'test needs posix.getresuid()')
     def test_getresuid(self):

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]