|
1 | 1 | """Base test setup for the psy-simple test suite."""
|
2 | 2 |
|
3 |
| - |
4 | 3 | # SPDX-FileCopyrightText: 2021-2024 Helmholtz-Zentrum Hereon
|
5 | 4 | # SPDX-FileCopyrightText: 2020-2021 Helmholtz-Zentrum Geesthacht
|
6 | 5 | # SPDX-FileCopyrightText: 2016-2024 University of Lausanne
|
|
11 | 10 | import os
|
12 | 11 | import subprocess as spr
|
13 | 12 | import sys
|
| 13 | +import time |
14 | 14 | from unittest import TestCase
|
15 | 15 |
|
16 | 16 | import numpy as np
|
@@ -97,11 +97,21 @@ def compare_figures(self, fname, tol=5, **kwargs):
|
97 | 97 | from matplotlib.testing.compare import compare_images
|
98 | 98 |
|
99 | 99 | 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 | + ) |
105 | 115 | self.assertIsNone(results, msg=results)
|
106 | 116 |
|
107 | 117 | def assertAlmostArrayEqual(
|
|
0 commit comments