Skip to content

Commit da49c09

Browse files
committed
Address review comments from picnixz
1 parent 9106878 commit da49c09

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

Lib/shutil.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class Error(OSError):
7676
pass
7777

7878
class ErrorGroup(Error):
79-
"""Raised when multiple exceptions have been caught"""
79+
"""Raised when multiple exceptions have been caught."""
8080

8181
class SameFileError(Error):
8282
"""Raised when source and destination are the same file."""

Lib/test/test_shutil.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,15 +1121,16 @@ def test_copytree_to_backpointing_symlink_gives_sensible_error_message(self):
11211121
self._assert_are_the_same_file_is_raised(src_dir, target_dir)
11221122

11231123
def _assert_are_the_same_file_is_raised(self, src_dir, target_dir):
1124-
try:
1124+
with self.assertRaises(Error) as cm:
11251125
shutil.copytree(src_dir, target_dir, dirs_exist_ok=True)
1126-
self.fail("shutil.Error should have been raised")
1127-
except Error as error:
1128-
self.assertEqual(len(error.args[0]), 1)
1129-
if sys.platform == "win32":
1130-
self.assertIn("it is being used by another process", error.args[0][0][2])
1131-
else:
1132-
self.assertIn("are the same file", error.args[0][0][2])
1126+
1127+
self.assertEqual(len(cm.exception.args[0]), 1)
1128+
if sys.platform == "win32":
1129+
self.assertIn(
1130+
"it is being used by another process", cm.exception.args[0][0][2]
1131+
)
1132+
else:
1133+
self.assertIn("are the same file", cm.exception.args[0][0][2])
11331134

11341135

11351136
class TestCopy(BaseTest, unittest.TestCase):

0 commit comments

Comments
 (0)