summaryrefslogtreecommitdiff
path: root/Lib/test/test_shutil.py
diff options
context:
space:
mode:
authorandrei kulakov <andrei.avk@gmail.com>2021-07-09 23:47:41 -0400
committerGitHub <noreply@github.com>2021-07-09 20:47:41 -0700
commit248173cc0483a9ad9261353302f1234cf9eb2ebe (patch)
tree1af4ee52325ed4a50696de8d68853cde4dc9464a /Lib/test/test_shutil.py
parentf24777c2b329974b69d2a3bf5cfc37e0fcace36c (diff)
downloadcpython-git-248173cc0483a9ad9261353302f1234cf9eb2ebe.tar.gz
bpo-43219: shutil.copyfile, raise a less confusing exception instead of IsADirectoryError (GH-27049)
Fixes the misleading IsADirectoryError to be FileNotFoundError.
Diffstat (limited to 'Lib/test/test_shutil.py')
-rw-r--r--Lib/test/test_shutil.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py
index 493c7e5f9f..e2574253d9 100644
--- a/Lib/test/test_shutil.py
+++ b/Lib/test/test_shutil.py
@@ -1249,6 +1249,15 @@ class TestCopy(BaseTest, unittest.TestCase):
# Make sure file is not corrupted.
self.assertEqual(read_file(src_file), 'foo')
+ @unittest.skipIf(MACOS or _winapi, 'On MACOS and Windows the errors are not confusing (though different)')
+ def test_copyfile_nonexistent_dir(self):
+ # Issue 43219
+ src_dir = self.mkdtemp()
+ src_file = os.path.join(src_dir, 'foo')
+ dst = os.path.join(src_dir, 'does_not_exist/')
+ write_file(src_file, 'foo')
+ self.assertRaises(FileNotFoundError, shutil.copyfile, src_file, dst)
+
class TestArchives(BaseTest, unittest.TestCase):