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