Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2)

Unified Diff: Lib/test/test_shutil.py

Issue 21697: shutil.copytree() handles symbolic directory incorrectly
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/shutil.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/test/test_shutil.py Fri Jul 10 22:26:44 2015 +0300
+++ b/Lib/test/test_shutil.py Fri Jul 10 16:15:43 2015 -0500
@@ -901,6 +901,26 @@
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)
+
+ assert not 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)
+ assert 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()
« no previous file with comments | « Lib/shutil.py ('k') | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+