Skip to content

Commit 9a7fe1a

Browse files
committed
new error names
1 parent 2b0cbac commit 9a7fe1a

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

fs/errors.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,18 @@ class RemoveRootError(OperationFailed):
241241
default_message = "root directory may not be removed"
242242

243243

244+
class IllegalMoveDestination(OperationFailed):
245+
"""Attempt to move a folder into its own subfolder."""
246+
247+
default_message = "'{path}' cannot be moved into itself"
248+
249+
250+
class IllegalCopyDestination(OperationFailed):
251+
"""Attempt to copy a folder into its own subfolder."""
252+
253+
default_message = "'{path}' cannot be copied into itself"
254+
255+
244256
class ResourceError(FSError):
245257
"""Base exception class for error associated with a specific resource."""
246258

@@ -304,12 +316,6 @@ class DirectoryNotEmpty(ResourceError):
304316
default_message = "directory '{path}' is not empty"
305317

306318

307-
class InvalidMoveOperation(ResourceError):
308-
"""Attempt to move a folder into its own subfolder."""
309-
310-
default_message = "you cannot move '{path}' into its own subfolder"
311-
312-
313319
class ResourceLocked(ResourceError):
314320
"""Attempt to use a locked resource."""
315321

fs/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1924,7 +1924,7 @@ def test_movedir_into_its_own_subfolder(self):
19241924
sub = folder.makedir("sub")
19251925
sub.writetext("file2.txt", "Hello2")
19261926

1927-
with self.assertRaises(errors.InvalidMoveOperation):
1927+
with self.assertRaises(errors.IllegalMoveDestination):
19281928
self.fs.movedir("folder", "folder/sub/")
19291929

19301930
def test_match(self):

0 commit comments

Comments
 (0)