diff options
author | Berker Peksag <berker.peksag@gmail.com> | 2015-07-25 11:55:06 (GMT) |
---|---|---|
committer | Berker Peksag <berker.peksag@gmail.com> | 2015-07-25 11:55:06 (GMT) |
commit | 940d69d4441393fc15f3418364d305cd683ad983 (patch) | |
tree | d5ecc72637dfabb4080fb8c5f3ba1e1e338142fe /Lib/test/test_shutil.py | |
parent | bf1d4b6d7d3a997402535b4ab960b9373570a546 (diff) | |
parent | 5a294d822b7f5732135662907ec1a1d4a7b0fc9a (diff) | |
download | cpython-940d69d4441393fc15f3418364d305cd683ad983.zip cpython-940d69d4441393fc15f3418364d305cd683ad983.tar.gz cpython-940d69d4441393fc15f3418364d305cd683ad983.tar.bz2 |
Issue #21697: shutil.copytree() now correctly handles symbolic links that point to directories.
Patch by Eduardo Seabra and Thomas Kluyver.
Diffstat (limited to 'Lib/test/test_shutil.py')
-rw-r--r-- | Lib/test/test_shutil.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py index c5545ba..5183c3c 100644 --- a/Lib/test/test_shutil.py +++ b/Lib/test/test_shutil.py @@ -901,6 +901,26 @@ class TestShutil(unittest.TestCase): shutil.copytree(src_dir, dst_dir, symlinks=True) self.assertIn('test.txt', os.listdir(dst_dir)) + @support.skip_unless_symlink + def test_copytree_symlink_dir(self): + src_dir = self.mkdtemp() + dst_dir = os.path.join(self.mkdtemp(), 'destination') + os.mkdir(os.path.join(src_dir, 'real_dir')) + with open(os.path.join(src_dir, 'real_dir', 'test.txt'), 'w'): + pass + os.symlink(os.path.join(src_dir, 'real_dir'), + os.path.join(src_dir, 'link_to_dir'), + target_is_directory=True) + + shutil.copytree(src_dir, dst_dir, symlinks=False) + self.assertFalse(os.path.islink(os.path.join(dst_dir, 'link_to_dir'))) + self.assertIn('test.txt', os.listdir(os.path.join(dst_dir, 'link_to_dir'))) + + dst_dir = os.path.join(self.mkdtemp(), 'destination2') + shutil.copytree(src_dir, dst_dir, symlinks=True) + self.assertTrue(os.path.islink(os.path.join(dst_dir, 'link_to_dir'))) + self.assertIn('test.txt', os.listdir(os.path.join(dst_dir, 'link_to_dir'))) + def _copy_file(self, method): fname = 'test.txt' tmpdir = self.mkdtemp() |