diff options
| author | Christian Heimes <christian@cheimes.de> | 2013-08-16 22:55:39 (GMT) |
|---|---|---|
| committer | Christian Heimes <christian@cheimes.de> | 2013-08-16 22:55:39 (GMT) |
| commit | a3811e4b8f70790a3dc8768a455cb8836670de37 (patch) | |
| tree | 000e0496c1fc58dd59ecede50e2cd756746f3cd9 /Lib/test/test_shutil.py | |
| parent | 824f7f366d1b54d2d3100c3130c04cf1dfb4b47c (diff) | |
| parent | 7bf1125e9fe7fda150af3962c94f857b8461bfd7 (diff) | |
| download | cpython-a3811e4b8f70790a3dc8768a455cb8836670de37.zip cpython-a3811e4b8f70790a3dc8768a455cb8836670de37.tar.gz cpython-a3811e4b8f70790a3dc8768a455cb8836670de37.tar.bz2 | |
merge
Diffstat (limited to 'Lib/test/test_shutil.py')
| -rw-r--r-- | Lib/test/test_shutil.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py index acaffdd..9af7da7 100644 --- a/Lib/test/test_shutil.py +++ b/Lib/test/test_shutil.py @@ -726,6 +726,32 @@ class TestShutil(unittest.TestCase): shutil.rmtree(src_dir) shutil.rmtree(os.path.dirname(dst_dir)) + def test_copytree_retains_permissions(self): + tmp_dir = tempfile.mkdtemp() + src_dir = os.path.join(tmp_dir, 'source') + os.mkdir(src_dir) + dst_dir = os.path.join(tmp_dir, 'destination') + self.addCleanup(shutil.rmtree, tmp_dir) + + os.chmod(src_dir, 0o777) + write_file((src_dir, 'permissive.txt'), '123') + os.chmod(os.path.join(src_dir, 'permissive.txt'), 0o777) + write_file((src_dir, 'restrictive.txt'), '456') + os.chmod(os.path.join(src_dir, 'restrictive.txt'), 0o600) + restrictive_subdir = tempfile.mkdtemp(dir=src_dir) + os.chmod(restrictive_subdir, 0o600) + + shutil.copytree(src_dir, dst_dir) + self.assertEquals(os.stat(src_dir).st_mode, os.stat(dst_dir).st_mode) + self.assertEquals(os.stat(os.path.join(src_dir, 'permissive.txt')).st_mode, + os.stat(os.path.join(dst_dir, 'permissive.txt')).st_mode) + self.assertEquals(os.stat(os.path.join(src_dir, 'restrictive.txt')).st_mode, + os.stat(os.path.join(dst_dir, 'restrictive.txt')).st_mode) + restrictive_subdir_dst = os.path.join(dst_dir, + os.path.split(restrictive_subdir)[1]) + self.assertEquals(os.stat(restrictive_subdir).st_mode, + os.stat(restrictive_subdir_dst).st_mode) + @unittest.skipUnless(hasattr(os, 'link'), 'requires os.link') def test_dont_copy_file_onto_link_to_itself(self): # Temporarily disable test on Windows. |
