diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2012-12-04 09:07:16 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2012-12-04 09:07:16 (GMT) |
commit | 8c7c697e49336ef764462494a02250023716e82e (patch) | |
tree | ccc3f96f0019d994b4ba16ce283cad22b1e1de68 /Lib/test | |
parent | 74635c91776e4758598d635376dd57e406d3235c (diff) | |
download | cpython-8c7c697e49336ef764462494a02250023716e82e.zip cpython-8c7c697e49336ef764462494a02250023716e82e.tar.gz cpython-8c7c697e49336ef764462494a02250023716e82e.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.
--
Kubilay Kocak (koobs) asked me on IRC to backport this fix to Python 2.7: done!
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_posix.py | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py index 2eba770..7214efa 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(test_support.TESTFN) new_dummy_symlink_st = os.lstat(_DUMMY_SYMLINK) |