Skip to content

Commit

Permalink
Address review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
barneygale committed Aug 23, 2024
1 parent d371b89 commit 7f5b1ab
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions Lib/test/test_pathlib/test_pathlib_abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1772,10 +1772,8 @@ def test_copy_symlink_to_existing_symlink(self):
target = base / 'copyTarget'
source.symlink_to(base / 'fileA')
target.symlink_to(base / 'dirC')
with self.assertRaises(OSError):
source.copy(target)
with self.assertRaises(OSError):
source.copy(target, follow_symlinks=False)
self.assertRaises(OSError, source.copy, target)
self.assertRaises(OSError, source.copy, target, follow_symlinks=False)

@needs_symlinks
def test_copy_symlink_to_existing_directory_symlink(self):
Expand All @@ -1784,10 +1782,8 @@ def test_copy_symlink_to_existing_directory_symlink(self):
target = base / 'copyTarget'
source.symlink_to(base / 'fileA')
target.symlink_to(base / 'dirC')
with self.assertRaises(OSError):
source.copy(target)
with self.assertRaises(OSError):
source.copy(target, follow_symlinks=False)
self.assertRaises(OSError, source.copy, target)
self.assertRaises(OSError, source.copy, target, follow_symlinks=False)

@needs_symlinks
def test_copy_directory_symlink_follow_symlinks_false(self):
Expand All @@ -1805,13 +1801,15 @@ def test_copy_directory_symlink_to_itself(self):
base = self.cls(self.base)
source = base / 'linkB'
self.assertRaises(OSError, source.copy, source)
self.assertRaises(OSError, source.copy, source, follow_symlinks=False)

@needs_symlinks
def test_copy_directory_symlink_into_itself(self):
base = self.cls(self.base)
source = base / 'linkB'
target = base / 'linkB' / 'copyB'
self.assertRaises(OSError, source.copy, target)
self.assertRaises(OSError, source.copy, target, follow_symlinks=False)
self.assertFalse(target.exists())

@needs_symlinks
Expand All @@ -1821,10 +1819,8 @@ def test_copy_directory_symlink_to_existing_symlink(self):
target = base / 'copyTarget'
source.symlink_to(base / 'dirC')
target.symlink_to(base / 'fileA')
with self.assertRaises(FileExistsError):
source.copy(target)
with self.assertRaises(FileExistsError):
source.copy(target, follow_symlinks=False)
self.assertRaises(FileExistsError, source.copy, target)
self.assertRaises(FileExistsError, source.copy, target, follow_symlinks=False)

@needs_symlinks
def test_copy_directory_symlink_to_existing_directory_symlink(self):
Expand All @@ -1833,10 +1829,8 @@ def test_copy_directory_symlink_to_existing_directory_symlink(self):
target = base / 'copyTarget'
source.symlink_to(base / 'dirC' / 'dirD')
target.symlink_to(base / 'dirC')
with self.assertRaises(FileExistsError):
source.copy(target)
with self.assertRaises(FileExistsError):
source.copy(target, follow_symlinks=False)
self.assertRaises(FileExistsError, source.copy, target)
self.assertRaises(FileExistsError, source.copy, target, follow_symlinks=False)

def test_copy_file_to_existing_file(self):
base = self.cls(self.base)
Expand All @@ -1851,8 +1845,7 @@ def test_copy_file_to_existing_directory(self):
base = self.cls(self.base)
source = base / 'fileA'
target = base / 'dirA'
with self.assertRaises(OSError):
source.copy(target)
self.assertRaises(OSError, source.copy, target)

@needs_symlinks
def test_copy_file_to_existing_symlink(self):
Expand Down Expand Up @@ -1897,6 +1890,7 @@ def test_copy_file_to_itself(self):
source = base / 'empty'
source.write_bytes(b'')
self.assertRaises(OSError, source.copy, source)
self.assertRaises(OSError, source.copy, source, follow_symlinks=False)

def test_copy_dir_simple(self):
base = self.cls(self.base)
Expand Down Expand Up @@ -1988,6 +1982,7 @@ def test_copy_dir_to_itself(self):
base = self.cls(self.base)
source = base / 'dirC'
self.assertRaises(OSError, source.copy, source)
self.assertRaises(OSError, source.copy, source, follow_symlinks=False)

def test_copy_dir_to_itself_on_error(self):
base = self.cls(self.base)
Expand All @@ -2002,6 +1997,7 @@ def test_copy_dir_into_itself(self):
source = base / 'dirC'
target = base / 'dirC' / 'dirD' / 'copyC'
self.assertRaises(OSError, source.copy, target)
self.assertRaises(OSError, source.copy, target, follow_symlinks=False)
self.assertFalse(target.exists())

def test_copy_missing_on_error(self):
Expand Down

0 comments on commit 7f5b1ab

Please sign in to comment.