MCPcopy Index your code
hub / github.com/python/cpython / test_copyxattr_symlinks

Method test_copyxattr_symlinks

Lib/test/test_shutil.py:1323–1342  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1321 @os_helper.skip_unless_xattr
1322 @os_helper.skip_unless_dac_override
1323 def test_copyxattr_symlinks(self):
1324 # On Linux, it's only possible to access non-user xattr for symlinks;
1325 # which in turn require root privileges. This test should be expanded
1326 # as soon as other platforms gain support for extended attributes.
1327 tmp_dir = self.mkdtemp()
1328 src = os.path.join(tmp_dir, 'foo')
1329 src_link = os.path.join(tmp_dir, 'baz')
1330 create_file(src, 'foo')
1331 os.symlink(src, src_link)
1332 os.setxattr(src, 'trusted.foo', b'42')
1333 os.setxattr(src_link, 'trusted.foo', b'43', follow_symlinks=False)
1334 dst = os.path.join(tmp_dir, 'bar')
1335 dst_link = os.path.join(tmp_dir, 'qux')
1336 create_file(dst, 'bar')
1337 os.symlink(dst, dst_link)
1338 shutil._copyxattr(src_link, dst_link, follow_symlinks=False)
1339 self.assertEqual(os.getxattr(dst_link, 'trusted.foo', follow_symlinks=False), b'43')
1340 self.assertRaises(OSError, os.getxattr, dst, 'trusted.foo')
1341 shutil._copyxattr(src_link, dst, follow_symlinks=False)
1342 self.assertEqual(os.getxattr(dst, 'trusted.foo'), b'43')
1343
1344 ### shutil.copy
1345

Callers

nothing calls this directly

Calls 7

mkdtempMethod · 0.80
setxattrMethod · 0.80
getxattrMethod · 0.80
create_fileFunction · 0.70
joinMethod · 0.45
assertEqualMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected