@@ -92,13 +92,13 @@ def test_move_dir(self):
92
92
93
93
class TestMove (unittest .TestCase ):
94
94
def test_move_file_tempfs (self ):
95
- with open_fs ("temp://" ) as a , open_fs ("temp://" ) as b :
96
- dir_a = a .makedir ("dir " )
97
- dir_b = b . makedir ( "subdir " )
98
- dir_b . writetext ( "file.txt" , "Content " )
99
- fs .move .move_file (dir_b , "file.txt" , dir_a , "here .txt" )
100
- self .assertEqual (a .readtext ("dir/here .txt" ), "Content" )
101
- self .assertFalse (b .exists ("subdir /file.txt" ))
95
+ with open_fs ("temp://" ) as src , open_fs ("temp://" ) as dst :
96
+ src_dir = src .makedir ("Some subfolder " )
97
+ src_dir . writetext ( "file.txt" , "Content " )
98
+ dst_dir = dst . makedir ( "dest dir " )
99
+ fs .move .move_file (src_dir , "file.txt" , dst_dir , "target .txt" )
100
+ self .assertEqual (dst .readtext ("dest dir/target .txt" ), "Content" )
101
+ self .assertFalse (src .exists ("Some subfolder /file.txt" ))
102
102
103
103
def test_move_file_fs_urls (self ):
104
104
# create a temp dir to work on
@@ -111,10 +111,10 @@ def test_move_file_fs_urls(self):
111
111
"osfs://" + join (path , "subdir_src" ),
112
112
"file.txt" ,
113
113
"osfs://" + join (path , "subdir_dst" ),
114
- "file .txt" ,
114
+ "target .txt" ,
115
115
)
116
116
self .assertFalse (subdir_src .exists ("file.txt" ))
117
- self .assertEqual (tmp .readtext ("subdir_dst/file .txt" ), "Content" )
117
+ self .assertEqual (tmp .readtext ("subdir_dst/target .txt" ), "Content" )
118
118
119
119
def test_move_file_same_fs_read_only_source (self ):
120
120
with open_fs ("temp://" ) as tmp :
@@ -123,21 +123,21 @@ def test_move_file_same_fs_read_only_source(self):
123
123
src = read_only (open_fs (path ))
124
124
dst = tmp .makedir ("sub" )
125
125
with self .assertRaises (ResourceReadOnly ):
126
- fs .move .move_file (src , "file.txt" , dst , "file .txt" )
126
+ fs .move .move_file (src , "file.txt" , dst , "target_file .txt" )
127
127
self .assertFalse (
128
- dst .exists ("file .txt" ), "file should not have been copied over"
128
+ dst .exists ("target_file .txt" ), "file should not have been copied over"
129
129
)
130
130
self .assertTrue (src .exists ("file.txt" ))
131
131
132
132
def test_move_file_read_only_mem_source (self ):
133
133
with open_fs ("mem://" ) as src , open_fs ("mem://" ) as dst :
134
134
src .writetext ("file.txt" , "Content" )
135
- sub = dst .makedir ("sub" )
135
+ dst_sub = dst .makedir ("sub" )
136
136
src_ro = read_only (src )
137
137
with self .assertRaises (ResourceReadOnly ):
138
- fs .move .move_file (src_ro , "file.txt" , sub , "file .txt" )
138
+ fs .move .move_file (src_ro , "file.txt" , dst_sub , "target .txt" )
139
139
self .assertFalse (
140
- sub .exists ("file .txt" ), "file should not have been copied over"
140
+ dst_sub .exists ("target .txt" ), "file should not have been copied over"
141
141
)
142
142
self .assertTrue (src .exists ("file.txt" ))
143
143
@@ -146,9 +146,9 @@ def test_move_file_read_only_mem_dest(self):
146
146
src .writetext ("file.txt" , "Content" )
147
147
dst_ro = read_only (dst )
148
148
with self .assertRaises (ResourceReadOnly ):
149
- fs .move .move_file (src , "file.txt" , dst_ro , "file .txt" )
149
+ fs .move .move_file (src , "file.txt" , dst_ro , "target .txt" )
150
150
self .assertFalse (
151
- dst_ro .exists ("file .txt" ), "file should not have been copied over"
151
+ dst_ro .exists ("target .txt" ), "file should not have been copied over"
152
152
)
153
153
self .assertTrue (src .exists ("file.txt" ))
154
154
@@ -158,9 +158,9 @@ def test_move_file_cleanup_on_error(self):
158
158
with mock .patch .object (src , "remove" ) as mck :
159
159
mck .side_effect = FSError
160
160
with self .assertRaises (FSError ):
161
- fs .move .move_file (src , "file.txt" , dst , "file .txt" )
161
+ fs .move .move_file (src , "file.txt" , dst , "target .txt" )
162
162
self .assertTrue (src .exists ("file.txt" ))
163
- self .assertFalse (dst .exists ("file .txt" ))
163
+ self .assertFalse (dst .exists ("target .txt" ))
164
164
165
165
def test_move_file_no_cleanup_on_error (self ):
166
166
with open_fs ("mem://" ) as src , open_fs ("mem://" ) as dst :
@@ -169,7 +169,7 @@ def test_move_file_no_cleanup_on_error(self):
169
169
mck .side_effect = FSError
170
170
with self .assertRaises (FSError ):
171
171
fs .move .move_file (
172
- src , "file.txt" , dst , "file .txt" , cleanup_dest_on_error = False
172
+ src , "file.txt" , dst , "target .txt" , cleanup_dst_on_error = False
173
173
)
174
174
self .assertTrue (src .exists ("file.txt" ))
175
- self .assertTrue (dst .exists ("file .txt" ))
175
+ self .assertTrue (dst .exists ("target .txt" ))
0 commit comments