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

Method test_copy_symlinks

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

Source from the content-addressed store, hash-verified

1361
1362 @os_helper.skip_unless_symlink
1363 def test_copy_symlinks(self):
1364 tmp_dir = self.mkdtemp()
1365 src = os.path.join(tmp_dir, 'foo')
1366 dst = os.path.join(tmp_dir, 'bar')
1367 src_link = os.path.join(tmp_dir, 'baz')
1368 create_file(src, 'foo')
1369 os.symlink(src, src_link)
1370 if hasattr(os, 'lchmod'):
1371 os.lchmod(src_link, stat.S_IRWXU | stat.S_IRWXO)
1372 # don't follow
1373 shutil.copy(src_link, dst, follow_symlinks=True)
1374 self.assertFalse(os.path.islink(dst))
1375 self.assertEqual(read_file(src), read_file(dst))
1376 os.remove(dst)
1377 # follow
1378 shutil.copy(src_link, dst, follow_symlinks=False)
1379 self.assertTrue(os.path.islink(dst))
1380 self.assertEqual(os.readlink(dst), os.readlink(src_link))
1381 if hasattr(os, 'lchmod'):
1382 self.assertEqual(os.lstat(src_link).st_mode,
1383 os.lstat(dst).st_mode)
1384
1385 ### shutil.copy2
1386

Callers

nothing calls this directly

Calls 13

read_fileFunction · 0.85
mkdtempMethod · 0.80
lchmodMethod · 0.80
assertFalseMethod · 0.80
islinkMethod · 0.80
assertTrueMethod · 0.80
lstatMethod · 0.80
create_fileFunction · 0.70
joinMethod · 0.45
copyMethod · 0.45
assertEqualMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected