(*args, extension, request, **kwargs)
| 199 | @_checked_on_freetype_version(freetype_version) |
| 200 | @functools.wraps(func) |
| 201 | def wrapper(*args, extension, request, **kwargs): |
| 202 | __tracebackhide__ = True |
| 203 | if 'extension' in old_sig.parameters: |
| 204 | kwargs['extension'] = extension |
| 205 | if 'request' in old_sig.parameters: |
| 206 | kwargs['request'] = request |
| 207 | |
| 208 | if extension not in comparable_formats(): |
| 209 | reason = { |
| 210 | 'gif': 'because ImageMagick is not installed', |
| 211 | 'pdf': 'because Ghostscript is not installed', |
| 212 | 'eps': 'because Ghostscript is not installed', |
| 213 | 'svg': 'because Inkscape is not installed', |
| 214 | }.get(extension, 'on this system') |
| 215 | pytest.skip(f"Cannot compare {extension} files {reason}") |
| 216 | |
| 217 | img = _ImageComparisonBase(func, tol=tol, remove_text=remove_text, |
| 218 | savefig_kwargs=savefig_kwargs) |
| 219 | matplotlib.testing.set_font_settings_for_testing() |
| 220 | |
| 221 | with _collect_new_figures() as figs: |
| 222 | func(*args, **kwargs) |
| 223 | |
| 224 | # If the test is parametrized in any way other than applied via |
| 225 | # this decorator, then we need to use a lock to prevent two |
| 226 | # processes from touching the same output file. |
| 227 | needs_lock = any( |
| 228 | marker.args[0] != 'extension' |
| 229 | for marker in request.node.iter_markers('parametrize')) |
| 230 | |
| 231 | if baseline_images is not None: |
| 232 | our_baseline_images = baseline_images |
| 233 | else: |
| 234 | # Allow baseline image list to be produced on the fly based on |
| 235 | # current parametrization. |
| 236 | our_baseline_images = request.getfixturevalue( |
| 237 | 'baseline_images') |
| 238 | |
| 239 | assert len(figs) == len(our_baseline_images), ( |
| 240 | f"Test generated {len(figs)} images but there are " |
| 241 | f"{len(our_baseline_images)} baseline images") |
| 242 | for fig, baseline in zip(figs, our_baseline_images): |
| 243 | img.compare(fig, baseline, extension, _lock=needs_lock) |
| 244 | |
| 245 | parameters = list(old_sig.parameters.values()) |
| 246 | if 'extension' not in old_sig.parameters: |
nothing calls this directly
no test coverage detected
searching dependent graphs…