Skip to content

Commit cada590

Browse files
miss-islingtonserhiy-storchakaAlexey Izbyshev
authored
[3.13] gh-102184: Test os.sync() only if the "walltime" resource is enabled (GH-155448) (GH-155463)
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 e45d456) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Alexey Izbyshev <izbyshev@ispras.ru>
1 parent 1abb945 commit cada590

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

Lib/test/test_posix.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def testNoArgFunctions(self):
7171
NO_ARG_FUNCTIONS = [ "ctermid", "getcwd", "getcwdb", "uname",
7272
"times", "getloadavg",
7373
"getegid", "geteuid", "getgid", "getgroups",
74-
"getpid", "getpgrp", "getppid", "getuid", "sync",
74+
"getpid", "getpgrp", "getppid", "getuid",
7575
]
7676

7777
for name in NO_ARG_FUNCTIONS:
@@ -81,6 +81,13 @@ def testNoArgFunctions(self):
8181
posix_func()
8282
self.assertRaises(TypeError, posix_func, 1)
8383

84+
# gh-102184: sync() can block for a long time.
85+
@support.requires_resource('walltime')
86+
@unittest.skipUnless(hasattr(posix, 'sync'), 'test needs posix.sync()')
87+
def test_sync(self):
88+
posix.sync()
89+
self.assertRaises(TypeError, posix.sync, 1)
90+
8491
@unittest.skipUnless(hasattr(posix, 'getresuid'),
8592
'test needs posix.getresuid()')
8693
def test_getresuid(self):

0 commit comments

Comments
 (0)