(self)
| 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 |
nothing calls this directly
no test coverage detected