summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorTrent Nelson <trent@trent.me>2012-08-21 23:41:43 (GMT)
committerTrent Nelson <trent@trent.me>2012-08-21 23:41:43 (GMT)
commitee253ebf6265741dd3f747965dfa753e68532353 (patch)
tree6e8a5fd9024798deb0677700f43040da23dc2ccc /Lib
parent1b47bf43a6328e98849ccc7fe0375966b5571452 (diff)
downloadcpython-ee253ebf6265741dd3f747965dfa753e68532353.zip
cpython-ee253ebf6265741dd3f747965dfa753e68532353.tar.gz
cpython-ee253ebf6265741dd3f747965dfa753e68532353.tar.bz2
Issue #15747: skip chflags UF_IMMUTABLE tests if EOPNOTSUPP is raised.
This is necessary for ZFS systems, which don't support UF_IMMUTABLE.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_posix.py23
1 files changed, 20 insertions, 3 deletions
diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py
index c04c679..b936dda 100644
--- a/Lib/test/test_posix.py
+++ b/Lib/test/test_posix.py
@@ -334,7 +334,16 @@ class PosixTester(unittest.TestCase):
def _test_chflags_regular_file(self, chflags_func, target_file):
st = os.stat(target_file)
self.assertTrue(hasattr(st, 'st_flags'))
- chflags_func(target_file, st.st_flags | stat.UF_IMMUTABLE)
+
+ # ZFS returns EOPNOTSUPP when attempting to set flag UF_IMMUTABLE.
+ try:
+ chflags_func(target_file, st.st_flags | stat.UF_IMMUTABLE)
+ except OSError as err:
+ if err.errno != errno.EOPNOTSUPP:
+ raise
+ msg = 'chflag UF_IMMUTABLE not supported by underlying fs'
+ self.skipTest(msg)
+
try:
new_st = os.stat(target_file)
self.assertEqual(st.st_flags | stat.UF_IMMUTABLE, new_st.st_flags)
@@ -363,8 +372,16 @@ class PosixTester(unittest.TestCase):
self.teardown_files.append(_DUMMY_SYMLINK)
dummy_symlink_st = os.lstat(_DUMMY_SYMLINK)
- posix.lchflags(_DUMMY_SYMLINK,
- dummy_symlink_st.st_flags | stat.UF_IMMUTABLE)
+ # ZFS returns EOPNOTSUPP when attempting to set flag UF_IMMUTABLE.
+ try:
+ posix.lchflags(_DUMMY_SYMLINK,
+ dummy_symlink_st.st_flags | stat.UF_IMMUTABLE)
+ except OSError as err:
+ if err.errno != errno.EOPNOTSUPP:
+ raise
+ msg = 'chflag UF_IMMUTABLE not supported by underlying fs'
+ self.skipTest(msg)
+
try:
new_testfn_st = os.stat(support.TESTFN)
new_dummy_symlink_st = os.lstat(_DUMMY_SYMLINK)