1111assert_raises (OSError , lambda : os .read (fd , 10 ))
1212assert_raises (FileNotFoundError , lambda : os .open ('DOES_NOT_EXIST' , os .O_RDONLY ))
1313assert_raises (FileNotFoundError , lambda : os .open ('DOES_NOT_EXIST' , os .O_WRONLY ))
14+ assert_raises (FileNotFoundError , lambda : os .rename ('DOES_NOT_EXIST' , 'DOES_NOT_EXIST 2' ))
1415
1516
1617assert os .O_RDONLY == 0
@@ -80,6 +81,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
8081
8182FILE_NAME = "test1"
8283FILE_NAME2 = "test2"
84+ FILE_NAME3 = "test3"
8385SYMLINK_FILE = "symlink"
8486SYMLINK_FOLDER = "symlink1"
8587FOLDER = "dir1"
@@ -104,6 +106,19 @@ def __exit__(self, exc_type, exc_val, exc_tb):
104106 assert os .read (fd , len (CONTENT3 )) == CONTENT3
105107 os .close (fd )
106108
109+ fname3 = os .path .join (tmpdir , FILE_NAME3 )
110+ os .rename (fname , fname3 )
111+ assert os .path .exists (fname ) == False
112+ assert os .path .exists (fname3 ) == True
113+
114+ fd = os .open (fname3 , 0 )
115+ assert os .read (fd , len (CONTENT2 ) + len (CONTENT3 )) == CONTENT2 + CONTENT3
116+ os .close (fd )
117+
118+ os .rename (fname3 , fname )
119+ assert os .path .exists (fname3 ) == False
120+ assert os .path .exists (fname ) == True
121+
107122 # wait a little bit to ensure that the file times aren't the same
108123 time .sleep (0.1 )
109124
0 commit comments