Skip to content

Commit 8ff7a0c

Browse files
committed
Merge branch 'test-fixes' into 'develop'
fix image comparison and add reference and test images as CI artifacts See merge request psyplot/psy-simple!39
2 parents 6c01d49 + 9766e89 commit 8ff7a0c

2 files changed

Lines changed: 18 additions & 6 deletions

File tree

.gitlab-ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ test:
6969
name: pipfile
7070
paths:
7171
- "ci/matrix/${SCENARIO}/*"
72+
- "tests/reference_figures/*.png"
73+
- "tests/test_figures/*.png"
7274
expire_in: 30 days
7375
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
7476

tests/_base_testing.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Base test setup for the psy-simple test suite."""
22

3-
43
# SPDX-FileCopyrightText: 2021-2024 Helmholtz-Zentrum Hereon
54
# SPDX-FileCopyrightText: 2020-2021 Helmholtz-Zentrum Geesthacht
65
# SPDX-FileCopyrightText: 2016-2024 University of Lausanne
@@ -11,6 +10,7 @@
1110
import os
1211
import subprocess as spr
1312
import sys
13+
import time
1414
from unittest import TestCase
1515

1616
import numpy as np
@@ -97,11 +97,21 @@ def compare_figures(self, fname, tol=5, **kwargs):
9797
from matplotlib.testing.compare import compare_images
9898

9999
plt.savefig(os.path.join(self.odir, fname), **kwargs)
100-
results = compare_images(
101-
os.path.join(ref_dir, fname),
102-
os.path.join(self.odir, fname),
103-
tol=tol,
104-
)
100+
try:
101+
results = compare_images(
102+
os.path.join(ref_dir, fname),
103+
os.path.join(self.odir, fname),
104+
tol=tol,
105+
)
106+
except Exception:
107+
# output file might be empty because not yet written, so just try
108+
# again
109+
time.sleep(3)
110+
results = compare_images(
111+
os.path.join(ref_dir, fname),
112+
os.path.join(self.odir, fname),
113+
tol=tol,
114+
)
105115
self.assertIsNone(results, msg=results)
106116

107117
def assertAlmostArrayEqual(

0 commit comments

Comments
 (0)