@@ -1816,23 +1816,35 @@ def test_move_file_onto_itself(self):
18161816 self .fs .move ("file.txt" , "file.txt" , overwrite = True )
18171817 self .assert_text ("file.txt" , "Hello" )
18181818
1819+ with self .assertRaises (errors .DestinationExists ):
1820+ self .fs .move ("file.txt" , "file.txt" , overwrite = False )
1821+
18191822 def test_move_file_onto_itself_relpath (self ):
18201823 subdir = self .fs .makedir ("sub" )
18211824 subdir .writetext ("file.txt" , "Hello" )
18221825 self .fs .move ("sub/file.txt" , "sub/../sub/file.txt" , overwrite = True )
18231826 self .assert_text ("sub/file.txt" , "Hello" )
18241827
1828+ with self .assertRaises (errors .DestinationExists ):
1829+ self .fs .move ("sub/file.txt" , "sub/../sub/file.txt" , overwrite = False )
1830+
18251831 def test_copy_file_onto_itself (self ):
18261832 self .fs .writetext ("file.txt" , "Hello" )
18271833 self .fs .copy ("file.txt" , "file.txt" , overwrite = True )
18281834 self .assert_text ("file.txt" , "Hello" )
18291835
1836+ with self .assertRaises (errors .DestinationExists ):
1837+ self .fs .copy ("file.txt" , "file.txt" , overwrite = False )
1838+
18301839 def test_copy_file_onto_itself_relpath (self ):
18311840 subdir = self .fs .makedir ("sub" )
18321841 subdir .writetext ("file.txt" , "Hello" )
18331842 self .fs .copy ("sub/file.txt" , "sub/../sub/file.txt" , overwrite = True )
18341843 self .assert_text ("sub/file.txt" , "Hello" )
18351844
1845+ with self .assertRaises (errors .DestinationExists ):
1846+ self .fs .copy ("sub/file.txt" , "sub/../sub/file.txt" , overwrite = False )
1847+
18361848 def test_copydir (self ):
18371849 self .fs .makedirs ("foo/bar/baz/egg" )
18381850 self .fs .writetext ("foo/bar/foofoo.txt" , "Hello" )
0 commit comments