Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
gh-108962: Skip test_tempfile.test_flags() if not supported
Skip test_tempfile.test_flags() if chflags() fails with "OSError:
[Errno 45] Operation not supported" (ex: on FreeBSD 13).
  • Loading branch information
vstinner committed Sep 5, 2023
commit 44b4336b6123a8182bbdf72d9a7ae242759bf7a3
14 changes: 14 additions & 0 deletions Lib/test/test_tempfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1837,6 +1837,20 @@ def test_modes(self):
@unittest.skipUnless(hasattr(os, 'chflags'), 'requires os.lchflags')
def test_flags(self):
flags = stat.UF_IMMUTABLE | stat.UF_NOUNLINK

# skip the test if these flags are not supported (ex: FreeBSD 13)
filename = TESTFN
try:
open(filename, "w").close()
try:
os.chflags(filename, flags)
except OSError as exc:
# "OSError: [Errno 45] Operation not supported"
self.skipTest("chflags() doesn't support "
"UF_IMMUTABLE|UF_NOUNLINK: {exc}")
finally:
support.unlink(filename)

d = self.do_create(recurse=3, dirs=2, files=2)
with d:
# Change files and directories flags recursively.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Skip ``test_tempfile.test_flags()`` if ``chflags()`` fails with "OSError:
[Errno 45] Operation not supported" (ex: on FreeBSD 13). Patch by Victor
Stinner.