Fixed #35323 -- Prevented file_move_safe() from trying to overwrite existing file when allow_overwrite is False.

This commit is contained in:
Ben Cail 2024-03-21 14:17:06 -04:00 committed by Mariusz Felisiak
parent b6e2b83901
commit 07c8d979ae
2 changed files with 9 additions and 9 deletions

View file

@ -426,9 +426,10 @@ class FileMoveSafeTests(unittest.TestCase):
handle_a, self.file_a = tempfile.mkstemp()
handle_b, self.file_b = tempfile.mkstemp()
# file_move_safe() raises OSError if the destination file exists and
# allow_overwrite is False.
with self.assertRaises(FileExistsError):
# file_move_safe() raises FileExistsError if the destination file
# exists and allow_overwrite is False.
msg = r"Destination file .* exists and allow_overwrite is False\."
with self.assertRaisesRegex(FileExistsError, msg):
file_move_safe(self.file_a, self.file_b, allow_overwrite=False)
# should allow it and continue on if allow_overwrite is True