diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2019-02-26 11:04:41 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-26 11:04:41 (GMT) |
commit | c606a9cbd48f69d3f4a09204c781dda9864218b7 (patch) | |
tree | a2847d175dac2288dff7541eeba3ff4b3737a169 /Lib/test/test_shutil.py | |
parent | d5a551c2694e32835bcdafc01d611f3227ca36b3 (diff) | |
download | cpython-c606a9cbd48f69d3f4a09204c781dda9864218b7.zip cpython-c606a9cbd48f69d3f4a09204c781dda9864218b7.tar.gz cpython-c606a9cbd48f69d3f4a09204c781dda9864218b7.tar.bz2 |
bpo-35652: shutil.copytree(copy_function=...) erroneously pass DirEntry instead of path str (GH-11997)
Diffstat (limited to 'Lib/test/test_shutil.py')
-rw-r--r-- | Lib/test/test_shutil.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py index ceafaed..678a190 100644 --- a/Lib/test/test_shutil.py +++ b/Lib/test/test_shutil.py @@ -859,6 +859,24 @@ class TestShutil(unittest.TestCase): with self.assertRaises(shutil.Error): shutil.copytree(src_dir, dst_dir) + def test_copytree_custom_copy_function(self): + # See: https://bugs.python.org/issue35648 + def custom_cpfun(a, b): + flag.append(None) + self.assertIsInstance(a, str) + self.assertIsInstance(b, str) + self.assertEqual(a, os.path.join(src, 'foo')) + self.assertEqual(b, os.path.join(dst, 'foo')) + + flag = [] + src = tempfile.mkdtemp() + dst = tempfile.mktemp() + self.addCleanup(shutil.rmtree, src) + with open(os.path.join(src, 'foo'), 'w') as f: + f.close() + shutil.copytree(src, dst, copy_function=custom_cpfun) + self.assertEqual(len(flag), 1) + @unittest.skipIf(os.name == 'nt', 'temporarily disabled on Windows') @unittest.skipUnless(hasattr(os, 'link'), 'requires os.link') def test_dont_copy_file_onto_link_to_itself(self): |