3
3
#
4
4
5
5
6
+ from copy import deepcopy
6
7
import os
7
8
import stat
8
9
import tempfile
@@ -101,22 +102,20 @@ def test_is_identical(self, scheme, fxt_datumaro_dataset, compare_media):
101
102
102
103
def test_cache_hit (self , fxt_datumaro_dataset ):
103
104
with tempfile .TemporaryDirectory () as tempdir :
104
- source_dataset = fxt_datumaro_dataset
105
- cached_dataset = init_arrow_cache (source_dataset , scheme = "AS-IS" , cache_dir = tempdir )
105
+ cached_dataset = init_arrow_cache (deepcopy (fxt_datumaro_dataset ), scheme = "AS-IS" , cache_dir = tempdir )
106
106
107
107
mapping = {}
108
108
for file in os .listdir (cached_dataset .data_path ):
109
109
mapping [file ] = os .stat (os .path .join (cached_dataset .data_path , file ))[stat .ST_MTIME ]
110
110
111
- cached_dataset = init_arrow_cache (source_dataset , scheme = "AS-IS" , cache_dir = tempdir )
111
+ cached_dataset = init_arrow_cache (deepcopy ( fxt_datumaro_dataset ) , scheme = "AS-IS" , cache_dir = tempdir )
112
112
113
113
for file in os .listdir (cached_dataset .data_path ):
114
114
assert mapping [file ] == os .stat (os .path .join (cached_dataset .data_path , file ))[stat .ST_MTIME ]
115
115
116
116
def test_no_cache_hit (self , fxt_datumaro_dataset ):
117
117
with tempfile .TemporaryDirectory () as tempdir :
118
- source_dataset = fxt_datumaro_dataset
119
- cached_dataset = init_arrow_cache (source_dataset , scheme = "AS-IS" , cache_dir = tempdir )
118
+ cached_dataset = init_arrow_cache (deepcopy (fxt_datumaro_dataset ), scheme = "AS-IS" , cache_dir = tempdir )
120
119
121
120
mapping = {}
122
121
for file in os .listdir (cached_dataset .data_path ):
@@ -125,7 +124,7 @@ def test_no_cache_hit(self, fxt_datumaro_dataset):
125
124
# sleep 1 second to invalidate cache
126
125
time .sleep (1 )
127
126
128
- cached_dataset = init_arrow_cache (source_dataset , scheme = "AS-IS" , cache_dir = tempdir , force = True )
127
+ cached_dataset = init_arrow_cache (deepcopy ( fxt_datumaro_dataset ) , scheme = "AS-IS" , cache_dir = tempdir , force = True )
129
128
130
129
for file in os .listdir (cached_dataset .data_path ):
131
130
assert mapping [file ] != os .stat (os .path .join (cached_dataset .data_path , file ))[stat .ST_MTIME ]
0 commit comments