Skip to content

Commit be52cfb

Browse files
committed
test: do deepcopy
Signed-off-by: Inhyuk Andy Cho <andy.inhyuk.jo@intel.com>
1 parent 759bfbc commit be52cfb

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

tests/unit/core/data/test_storage_caching.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#
44

55

6+
from copy import deepcopy
67
import os
78
import stat
89
import tempfile
@@ -101,22 +102,20 @@ def test_is_identical(self, scheme, fxt_datumaro_dataset, compare_media):
101102

102103
def test_cache_hit(self, fxt_datumaro_dataset):
103104
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)
106106

107107
mapping = {}
108108
for file in os.listdir(cached_dataset.data_path):
109109
mapping[file] = os.stat(os.path.join(cached_dataset.data_path, file))[stat.ST_MTIME]
110110

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)
112112

113113
for file in os.listdir(cached_dataset.data_path):
114114
assert mapping[file] == os.stat(os.path.join(cached_dataset.data_path, file))[stat.ST_MTIME]
115115

116116
def test_no_cache_hit(self, fxt_datumaro_dataset):
117117
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)
120119

121120
mapping = {}
122121
for file in os.listdir(cached_dataset.data_path):
@@ -125,7 +124,7 @@ def test_no_cache_hit(self, fxt_datumaro_dataset):
125124
# sleep 1 second to invalidate cache
126125
time.sleep(1)
127126

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)
129128

130129
for file in os.listdir(cached_dataset.data_path):
131130
assert mapping[file] != os.stat(os.path.join(cached_dataset.data_path, file))[stat.ST_MTIME]

0 commit comments

Comments
 (0)