diff options
| author | Trent Nelson <trent@trent.me> | 2012-08-21 23:59:31 +0000 | 
|---|---|---|
| committer | Trent Nelson <trent@trent.me> | 2012-08-21 23:59:31 +0000 | 
| commit | 75959cf2470e912fc4849bcc438d9ef44d4d64c9 (patch) | |
| tree | d1027e0d879b0ccca25a24f8aaf9abf3147899b6 | |
| parent | dda5edc007ecc7a583daf2ca881b17c8d95b12f4 (diff) | |
| download | cpython-git-75959cf2470e912fc4849bcc438d9ef44d4d64c9.tar.gz | |
Issue #15747: skip chflags UF_IMMUTABLE tests if EOPNOTSUPP is raised.
This is necessary for ZFS systems, which don't support UF_IMMUTABLE.
(Note: this commit is a manual merge of 78699:019a2390b014 as both
_test_chflags_regular_file and test_lchflags_symlink differ between
3.2 and default.)
| -rw-r--r-- | Lib/test/test_posix.py | 23 | ||||
| -rw-r--r-- | Misc/NEWS | 4 | 
2 files changed, 24 insertions, 3 deletions
| diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py index 11b3ba05fb..4e7a37c858 100644 --- a/Lib/test/test_posix.py +++ b/Lib/test/test_posix.py @@ -534,7 +534,17 @@ class PosixTester(unittest.TestCase):      def _test_chflags_regular_file(self, chflags_func, target_file, **kwargs):          st = os.stat(target_file)          self.assertTrue(hasattr(st, 'st_flags')) -        chflags_func(target_file, st.st_flags | stat.UF_IMMUTABLE, **kwargs) + +        # ZFS returns EOPNOTSUPP when attempting to set flag UF_IMMUTABLE. +        flags = st.st_flags | stat.UF_IMMUTABLE +        try: +            chflags_func(target_file, flags, **kwargs) +        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) @@ -568,8 +578,15 @@ class PosixTester(unittest.TestCase):              return posix.chflags(path, flags, follow_symlinks=False)          for fn in (posix.lchflags, chflags_nofollow): -            fn(_DUMMY_SYMLINK, -                           dummy_symlink_st.st_flags | stat.UF_IMMUTABLE) +            # ZFS returns EOPNOTSUPP when attempting to set flag UF_IMMUTABLE. +            flags = dummy_symlink_st.st_flags | stat.UF_IMMUTABLE +            try: +                fn(_DUMMY_SYMLINK, flags) +            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) @@ -86,6 +86,10 @@ Documentation  Tests  ----- +- Issue #15747: ZFS always returns EOPNOTSUPP when attempting to set the +  UF_IMMUTABLE flag (via either chflags or lchflags); refactor affected +  tests in test_posix.py to account for this. +  - Issue #15285: Refactor the approach for testing connect timeouts using    two external hosts that have been configured specifically for this type    of test. | 
