mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
[3.11] gh-108962: Skip test_tempfile.test_flags() if not supported (GH-108964) (#108968)
gh-108962: Skip test_tempfile.test_flags() if not supported (GH-108964)
Skip test_tempfile.test_flags() if chflags() fails with "OSError:
[Errno 45] Operation not supported" (ex: on FreeBSD 13).
(cherry picked from commit cd2ef21b07
)
Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
parent
effa2ecdcf
commit
9dd28d2da9
2 changed files with 20 additions and 1 deletions
|
@ -1726,9 +1726,25 @@ class TestTemporaryDirectory(BaseTestCase):
|
|||
d.cleanup()
|
||||
self.assertFalse(os.path.exists(d.name))
|
||||
|
||||
@unittest.skipUnless(hasattr(os, 'chflags'), 'requires os.lchflags')
|
||||
@unittest.skipUnless(hasattr(os, 'chflags'), 'requires os.chflags')
|
||||
def test_flags(self):
|
||||
flags = stat.UF_IMMUTABLE | stat.UF_NOUNLINK
|
||||
|
||||
# skip the test if these flags are not supported (ex: FreeBSD 13)
|
||||
filename = os_helper.TESTFN
|
||||
try:
|
||||
open(filename, "w").close()
|
||||
try:
|
||||
os.chflags(filename, flags)
|
||||
except OSError as exc:
|
||||
# "OSError: [Errno 45] Operation not supported"
|
||||
self.skipTest(f"chflags() doesn't support "
|
||||
f"UF_IMMUTABLE|UF_NOUNLINK: {exc}")
|
||||
else:
|
||||
os.chflags(filename, 0)
|
||||
finally:
|
||||
os_helper.unlink(filename)
|
||||
|
||||
d = self.do_create(recurse=3, dirs=2, files=2)
|
||||
with d:
|
||||
# Change files and directories flags recursively.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue