bpo-39047: Skip chflags UF_IMMUTABLE tests if EOPNOTSUPP is raised.

This is necessary for ZFS systems, which don't support UF_IMMUTABLE.
This commit is contained in:
Attila Jeges 2019-12-14 18:21:23 +01:00
parent 94d2c8df1a
commit 8872f3b8e6
1 changed files with 13 additions and 4 deletions

View File

@ -1493,10 +1493,19 @@ class TestTemporaryDirectory(BaseTestCase):
d = self.do_create(recurse=3, dirs=2, files=2) d = self.do_create(recurse=3, dirs=2, files=2)
with d: with d:
# Change files and directories flags recursively. # Change files and directories flags recursively.
for root, dirs, files in os.walk(d.name, topdown=False): # ZFS returns EOPNOTSUPP when attempting to set flag
for name in files: # UF_IMMUTABLE or UF_NOUNLINK.
os.chflags(os.path.join(root, name), flags) try:
os.chflags(root, flags) for root, dirs, files in os.walk(d.name, topdown=False):
for name in files:
os.chflags(os.path.join(root, name), flags)
os.chflags(root, flags)
except OSError as err:
if err.errno != errno.EOPNOTSUPP:
raise
msg = 'chflag UF_IMMUTABLE | UF_NONUNLINK not ' \
'supported by underlying fs'
self.skipTest(msg)
d.cleanup() d.cleanup()
self.assertFalse(os.path.exists(d.name)) self.assertFalse(os.path.exists(d.name))