88import sys
99import unittest
1010import warnings
11+ import string
1112
1213import matplotlib as mpl
1314import matplotlib .style
@@ -381,6 +382,7 @@ def test_plot(fig_test, fig_ref):
381382 fig_test.subplots().plot([1, 3, 5])
382383 fig_ref.subplots().plot([0, 1, 2], [1, 3, 5])
383384 """
385+ ALLOWED_CHARS = set (string .digits + string .ascii_letters + '_-[]()' )
384386 KEYWORD_ONLY = inspect .Parameter .KEYWORD_ONLY
385387 def decorator (func ):
386388 import pytest
@@ -389,13 +391,14 @@ def decorator(func):
389391
390392 @pytest .mark .parametrize ("ext" , extensions )
391393 def wrapper (* args , ext , request , ** kwargs ):
392- fn = request .node .name
394+ file_name = "" .join (c for c in request .node .name
395+ if c in ALLOWED_CHARS )
393396 try :
394397 fig_test = plt .figure ("test" )
395398 fig_ref = plt .figure ("reference" )
396399 func (* args , fig_test = fig_test , fig_ref = fig_ref , ** kwargs )
397- test_image_path = result_dir / (fn + "." + ext )
398- ref_image_path = result_dir / (fn + "-expected." + ext )
400+ test_image_path = result_dir / (file_name + "." + ext )
401+ ref_image_path = result_dir / (file_name + "-expected." + ext )
399402 fig_test .savefig (test_image_path )
400403 fig_ref .savefig (ref_image_path )
401404 _raise_on_image_difference (
0 commit comments