diff options
author | Barney Gale <barney.gale@gmail.com> | 2024-07-07 16:27:52 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-07 16:27:52 (GMT) |
commit | b765e4adf858ff8a8646f38933a5a355b6d72760 (patch) | |
tree | e262e56fe48fef32387b4fbcd821fa5a403455fd /Lib/test/test_pathlib/test_pathlib.py | |
parent | 3bddd07c2ada7cdadb55ea23a15037bd650e20ef (diff) | |
download | cpython-b765e4adf858ff8a8646f38933a5a355b6d72760.zip cpython-b765e4adf858ff8a8646f38933a5a355b6d72760.tar.gz cpython-b765e4adf858ff8a8646f38933a5a355b6d72760.tar.bz2 |
GH-73991: Fix "Operation not supported" on Fedora buildbot. (#121444)
Follow-up to #120806. Use `os_helper.skip_unless_xattr` to skip testing
xattr preservation when unsupported.
Diffstat (limited to 'Lib/test/test_pathlib/test_pathlib.py')
-rw-r--r-- | Lib/test/test_pathlib/test_pathlib.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/Lib/test/test_pathlib/test_pathlib.py b/Lib/test/test_pathlib/test_pathlib.py index 234e574..1328a86 100644 --- a/Lib/test/test_pathlib/test_pathlib.py +++ b/Lib/test/test_pathlib/test_pathlib.py @@ -656,8 +656,6 @@ class PathTest(test_pathlib_abc.DummyPathTest, PurePathTest): def test_copy_file_preserve_metadata(self): base = self.cls(self.base) source = base / 'fileA' - if hasattr(os, 'setxattr'): - os.setxattr(source, b'user.foo', b'42') if hasattr(os, 'chmod'): os.chmod(source, stat.S_IRWXU | stat.S_IRWXO) if hasattr(os, 'chflags') and hasattr(stat, 'UF_NODUMP'): @@ -670,12 +668,19 @@ class PathTest(test_pathlib_abc.DummyPathTest, PurePathTest): target_st = target.stat() self.assertLessEqual(source_st.st_atime, target_st.st_atime) self.assertLessEqual(source_st.st_mtime, target_st.st_mtime) - if hasattr(os, 'getxattr'): - self.assertEqual(os.getxattr(target, b'user.foo'), b'42') self.assertEqual(source_st.st_mode, target_st.st_mode) if hasattr(source_st, 'st_flags'): self.assertEqual(source_st.st_flags, target_st.st_flags) + @os_helper.skip_unless_xattr + def test_copy_file_preserve_metadata_xattrs(self): + base = self.cls(self.base) + source = base / 'fileA' + os.setxattr(source, b'user.foo', b'42') + target = base / 'copyA' + source.copy(target, preserve_metadata=True) + self.assertEqual(os.getxattr(target, b'user.foo'), b'42') + @needs_symlinks def test_copy_link_preserve_metadata(self): base = self.cls(self.base) |