8
8
import sys
9
9
import unittest
10
10
import warnings
11
+ import string
11
12
12
13
import matplotlib as mpl
13
14
import matplotlib .style
@@ -381,6 +382,7 @@ def test_plot(fig_test, fig_ref):
381
382
fig_test.subplots().plot([1, 3, 5])
382
383
fig_ref.subplots().plot([0, 1, 2], [1, 3, 5])
383
384
"""
385
+ ALLOWED_CHARS = set (string .digits + string .ascii_letters + '_-[]()' )
384
386
KEYWORD_ONLY = inspect .Parameter .KEYWORD_ONLY
385
387
def decorator (func ):
386
388
import pytest
@@ -389,13 +391,14 @@ def decorator(func):
389
391
390
392
@pytest .mark .parametrize ("ext" , extensions )
391
393
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 )
393
396
try :
394
397
fig_test = plt .figure ("test" )
395
398
fig_ref = plt .figure ("reference" )
396
399
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 )
399
402
fig_test .savefig (test_image_path )
400
403
fig_ref .savefig (ref_image_path )
401
404
_raise_on_image_difference (
0 commit comments