Skip to content

Commit 3b85c19

Browse files
author
Giampaolo Cimino
committed
add comments and code clean up
1 parent 8a66771 commit 3b85c19

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

tests/test_copy.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,19 +83,18 @@ def _delay_file_utime(self, filepath, delta_sec=None):
8383
file_access_mod_time = int(calendar.timegm(datetime.now().timetuple())) + delta_sec
8484
times = (file_access_mod_time, file_access_mod_time)
8585
os.utime(filepath, times)
86-
86+
8787
def test_copy_file_if_newer_dst_older(self):
8888
try:
8989
#create first dst ==> dst is older the src ==> file should be copied
9090
dst_dir = self._create_sandbox_dir()
9191
dst_file1 = self._touch(dst_dir, "file1.txt")
9292
self._write_file(dst_file1)
9393

94-
#time.sleep(3) #wait before create src file, to ensure src is older
95-
9694
src_dir = self._create_sandbox_dir()
9795
src_file1 = self._touch(src_dir, "file1.txt")
9896
self._write_file(src_file1)
97+
#ensure src file is newer than dst, changing its modification time
9998
self._delay_file_utime(src_file1, delta_sec=60)
10099

101100
src_fs = open_fs('osfs://' + src_dir)
@@ -137,8 +136,6 @@ def test_copy_file_if_newer_dst_is_newer(self):
137136
src_file1 = self._touch(src_dir, "file1.txt")
138137
self._write_file(src_file1)
139138

140-
#time.sleep(3) #wait before create dst file, to ensure dst is older
141-
142139
dst_dir = self._create_sandbox_dir()
143140
dst_file1 = self._touch(dst_dir, "file1.txt")
144141
self._write_file(dst_file1)
@@ -164,11 +161,10 @@ def test_copy_fs_if_newer_dst_older(self):
164161
dst_file1 = self._touch(dst_dir, "file1.txt")
165162
self._write_file(dst_file1)
166163

167-
#time.sleep(3) #wait before create src file, to ensure src is older
168-
169164
src_dir = self._create_sandbox_dir()
170165
src_file1 = self._touch(src_dir, "file1.txt")
171166
self._write_file(src_file1)
167+
#ensure src file is newer than dst, changing its modification time
172168
self._delay_file_utime(src_file1, delta_sec=60)
173169

174170
src_fs = open_fs('osfs://' + src_dir)
@@ -200,7 +196,7 @@ def test_copy_fs_if_newer_when_dst_doesnt_exists(self):
200196

201197
src_file2 = self._touch(src_dir, "one_level_down" + os.sep + "file2.txt")
202198
self._write_file(src_file2)
203-
199+
204200
dst_dir = self._create_sandbox_dir()
205201

206202
src_fs = open_fs('osfs://' + src_dir)
@@ -230,11 +226,10 @@ def test_copy_fs_if_newer_dont_copy_when_dst_exists(self):
230226
src_file1 = self._touch(src_dir, "file1.txt")
231227
self._write_file(src_file1)
232228

233-
#time.sleep(3) #wait before create dst file, to ensure dst is older
234-
235229
dst_dir = self._create_sandbox_dir()
236230
dst_file1 = self._touch(dst_dir, "file1.txt")
237231
self._write_file(dst_file1)
232+
#ensure dst file is newer than src, changing its modification time
238233
self._delay_file_utime(dst_file1, delta_sec=60)
239234

240235
src_fs = open_fs('osfs://' + src_dir)
@@ -271,6 +266,7 @@ def test_copy_dir_if_newer_one_dst_doesnt_exist(self):
271266
dst_dir = self._create_sandbox_dir()
272267
dst_file1 = self._touch(dst_dir, "file1.txt")
273268
self._write_file(dst_file1)
269+
#ensure dst file is newer than src, changing its modification time
274270
self._delay_file_utime(dst_file1, delta_sec=60)
275271

276272
src_fs = open_fs('osfs://' + src_dir)
@@ -300,7 +296,6 @@ def test_copy_dir_if_newer_same_fs(self):
300296
dst_dir = self._create_sandbox_dir(home=src_dir)
301297

302298
src_fs = open_fs('osfs://' + src_dir)
303-
# dst_fs = open_fs('osfs://' + dst_dir)
304299

305300
copied = []
306301
def on_copy(src_fs, src_path, dst_fs, dst_path):

0 commit comments

Comments
 (0)