@@ -356,12 +356,11 @@ def image_comparison(baseline_images, extensions=None, tol=0,
356
356
357
357
358
358
def check_figures_equal (* , extensions = ("png" , "pdf" , "svg" ), tol = 0 ):
359
- """
360
- Decorator for test cases that generate and compare two figures.
359
+ """Decorator for test cases that generate and compare two figures.
361
360
362
- The decorated function must take two arguments, *fig_test* and *fig_ref*,
363
- and draw the test and reference images on them. After the function
364
- returns, the figures are saved and compared.
361
+ The decorated function must take two keyword arguments, *fig_test*
362
+ and *fig_ref*, and draw the test and reference images on them.
363
+ After the function returns, the figures are saved and compared.
365
364
366
365
This decorator should be preferred over `image_comparison` when possible in
367
366
order to keep the size of the test suite from ballooning.
@@ -382,6 +381,7 @@ def check_figures_equal(*, extensions=("png", "pdf", "svg"), tol=0):
382
381
def test_plot(fig_test, fig_ref):
383
382
fig_test.subplots().plot([1, 3, 5])
384
383
fig_ref.subplots().plot([0, 1, 2], [1, 3, 5])
384
+
385
385
"""
386
386
ALLOWED_CHARS = set (string .digits + string .ascii_letters + '_-[]()' )
387
387
KEYWORD_ONLY = inspect .Parameter .KEYWORD_ONLY
@@ -391,6 +391,11 @@ def decorator(func):
391
391
_ , result_dir = _image_directories (func )
392
392
old_sig = inspect .signature (func )
393
393
394
+ if not all (k in old_sig .parameters for k in {"fig_test" , "fig_ref" }):
395
+ raise ValueError ("The decorated function must have at least the "
396
+ "parameters 'fig_ref' and 'fig_test', but your "
397
+ f"function has the signature { old_sig } " )
398
+
394
399
@pytest .mark .parametrize ("ext" , extensions )
395
400
def wrapper (* args , ** kwargs ):
396
401
ext = kwargs ['ext' ]
0 commit comments