diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2023-09-08 13:14:57 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-08 13:14:57 (GMT) |
commit | b9dfe60e8d58518794bcb7895c19f1d328cfe4de (patch) | |
tree | 28fcfd6792af47383ad5640e8697707d7a8a752f /Lib/test | |
parent | 0855b2c8b69f02f86f837875acda148479e6a061 (diff) | |
download | cpython-b9dfe60e8d58518794bcb7895c19f1d328cfe4de.zip cpython-b9dfe60e8d58518794bcb7895c19f1d328cfe4de.tar.gz cpython-b9dfe60e8d58518794bcb7895c19f1d328cfe4de.tar.bz2 |
[3.12] gh-108962: Skip test_tempfile.test_flags() if not supported (GH-108964) (#108967)
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 cd2ef21b076b494224985e266c5f5f8b37c66618)
Co-authored-by: Victor Stinner <vstinner@python.org>
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_tempfile.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/Lib/test/test_tempfile.py b/Lib/test/test_tempfile.py index db08fb1..1673507 100644 --- a/Lib/test/test_tempfile.py +++ b/Lib/test/test_tempfile.py @@ -1834,9 +1834,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. |