Skip to content

Commit 0c79861

Browse files
authored
Avoid stale cache for multimodel statistics regression tests (#1030)
1 parent 68196fe commit 0c79861

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

tests/sample_data/multimodel_statistics/test_multimodel.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515
esmvaltool_sample_data = pytest.importorskip("esmvaltool_sample_data")
1616

17+
# Increase this number anytime you change the cached input data to the tests.
18+
TEST_REVISION = 1
19+
1720
CALENDAR_PARAMS = (
1821
pytest.param(
1922
'360_day',
@@ -41,6 +44,7 @@ def assert_array_almost_equal(this, other):
4144

4245
def preprocess_data(cubes, time_slice: dict = None):
4346
"""Regrid the data to the first cube and optional time-slicing."""
47+
# Increase TEST_REVISION anytime you make changes to this function.
4448
if time_slice:
4549
cubes = [extract_time(cube, **time_slice) for cube in cubes]
4650

@@ -61,14 +65,14 @@ def get_cache_key(value):
6165
"""Get a cache key that is hopefully unique enough for unpickling.
6266
6367
If this doesn't avoid problems with unpickling the cached data,
64-
manually clean the pytest cache with the command `pytest --cache-
65-
clear`.
68+
manually clean the pytest cache with the command `pytest --cache-clear`.
6669
"""
6770
return ' '.join([
6871
str(value),
6972
iris.__version__,
7073
np.__version__,
7174
sys.version,
75+
f"rev-{TEST_REVISION}",
7276
])
7377

7478

@@ -82,6 +86,7 @@ def timeseries_cubes_month(request):
8286
if data:
8387
cubes = pickle.loads(data.encode('latin1'))
8488
else:
89+
# Increase TEST_REVISION anytime you make changes here.
8590
time_slice = {
8691
'start_year': 1985,
8792
'end_year': 1987,
@@ -111,6 +116,7 @@ def timeseries_cubes_day(request):
111116
cubes = pickle.loads(data.encode('latin1'))
112117

113118
else:
119+
# Increase TEST_REVISION anytime you make changes here.
114120
time_slice = {
115121
'start_year': 2001,
116122
'end_year': 2002,

0 commit comments

Comments
 (0)