From 07c8d979aecf5f1f71ce4f174369df39f24d24b3 Mon Sep 17 00:00:00 2001 From: Ben Cail Date: Thu, 21 Mar 2024 14:17:06 -0400 Subject: Fixed #35323 -- Prevented file_move_safe() from trying to overwrite existing file when allow_overwrite is False. --- tests/files/tests.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/files/tests.py b/tests/files/tests.py index 9d3a471cb3..4f6d1fa74b 100644 --- a/tests/files/tests.py +++ b/tests/files/tests.py @@ -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 -- cgit v1.3