Skip to content

Commit b765e4a

Browse files
authored
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.
1 parent 3bddd07 commit b765e4a

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Lib/test/test_pathlib/test_pathlib.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -656,8 +656,6 @@ def test_open_unbuffered(self):
656656
def test_copy_file_preserve_metadata(self):
657657
base = self.cls(self.base)
658658
source = base / 'fileA'
659-
if hasattr(os, 'setxattr'):
660-
os.setxattr(source, b'user.foo', b'42')
661659
if hasattr(os, 'chmod'):
662660
os.chmod(source, stat.S_IRWXU | stat.S_IRWXO)
663661
if hasattr(os, 'chflags') and hasattr(stat, 'UF_NODUMP'):
@@ -670,12 +668,19 @@ def test_copy_file_preserve_metadata(self):
670668
target_st = target.stat()
671669
self.assertLessEqual(source_st.st_atime, target_st.st_atime)
672670
self.assertLessEqual(source_st.st_mtime, target_st.st_mtime)
673-
if hasattr(os, 'getxattr'):
674-
self.assertEqual(os.getxattr(target, b'user.foo'), b'42')
675671
self.assertEqual(source_st.st_mode, target_st.st_mode)
676672
if hasattr(source_st, 'st_flags'):
677673
self.assertEqual(source_st.st_flags, target_st.st_flags)
678674

675+
@os_helper.skip_unless_xattr
676+
def test_copy_file_preserve_metadata_xattrs(self):
677+
base = self.cls(self.base)
678+
source = base / 'fileA'
679+
os.setxattr(source, b'user.foo', b'42')
680+
target = base / 'copyA'
681+
source.copy(target, preserve_metadata=True)
682+
self.assertEqual(os.getxattr(target, b'user.foo'), b'42')
683+
679684
@needs_symlinks
680685
def test_copy_link_preserve_metadata(self):
681686
base = self.cls(self.base)

0 commit comments

Comments
 (0)