@@ -359,9 +359,9 @@ def check_figures_equal(*, extensions=("png", "pdf", "svg"), tol=0):
359359 """
360360 Decorator for test cases that generate and compare two figures.
361361
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.
365365
366366 This decorator should be preferred over `image_comparison` when possible in
367367 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):
382382 def test_plot(fig_test, fig_ref):
383383 fig_test.subplots().plot([1, 3, 5])
384384 fig_ref.subplots().plot([0, 1, 2], [1, 3, 5])
385+
385386 """
386387 ALLOWED_CHARS = set (string .digits + string .ascii_letters + '_-[]()' )
387388 KEYWORD_ONLY = inspect .Parameter .KEYWORD_ONLY
@@ -391,6 +392,11 @@ def decorator(func):
391392 _ , result_dir = _image_directories (func )
392393 old_sig = inspect .signature (func )
393394
395+ if not all (k in old_sig .parameters for k in {"fig_test" , "fig_ref" }):
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+
394400 @pytest .mark .parametrize ("ext" , extensions )
395401 def wrapper (* args , ** kwargs ):
396402 ext = kwargs ['ext' ]
0 commit comments