99
1010import matplotlib as mpl
1111import matplotlib .pyplot as plt
12- from matplotlib .testing import _has_tex_package , _check_for_pgf
13- from matplotlib .testing .compare import compare_images , ImageComparisonFailure
1412from matplotlib .backends .backend_pgf import FigureCanvasPgf , PdfPages
13+ from matplotlib .backends .backend_pdf import FigureCanvasPdf
14+ from matplotlib .testing import _has_tex_package , _check_for_pgf
15+ from matplotlib .testing .compare import compare_images
16+ from matplotlib .testing .exceptions import ImageComparisonFailure
1517from matplotlib .testing .decorators import (
1618 _image_directories , check_figures_equal , image_comparison )
1719from matplotlib .testing ._markers import (
@@ -377,7 +379,6 @@ def test_sketch_params():
377379 assert baseline in buf
378380
379381
380- < << << << HEAD
381382# test to make sure that the document font size is set consistently (see #26892)
382383@needs_pgf_xelatex
383384@pytest .mark .skipif (
@@ -400,13 +401,24 @@ def test_document_font_size():
400401 label = r'\normalsize the document font size is \the\fontdimen6\font'
401402 )
402403 plt .legend ()
403- == == == =
404+
405+
404406@needs_pgf_xelatex
405407@pytest .mark .backend ('pgf' )
406- @image_comparison (['hatch_linewidth' ], extensions = ['pdf' ])
407408def test_pgf_hatch_linewidth ():
408409 mpl .backend_bases .register_backend ('pdf' , FigureCanvasPgf )
409410 mpl .rcParams ['hatch.linewidth' ] = 0.1
410411
411412 plt .bar (1 , 1 , color = 'white' , edgecolor = 'black' , hatch = '/' )
412- > >> >> >> 7 cbcd44f9a (Fix hatch linewidth in PGF )
413+ error = None
414+ try :
415+ compare_figure ('hatch_linewidth.pdf' )
416+ except ImageComparisonFailure as e :
417+ # Store if error
418+ error = e
419+ # Restore backend to not mess up other tests
420+ mpl .backend_bases .register_backend ('pdf' , FigureCanvasPdf )
421+
422+ if error is not None :
423+ # Re-raise stored error
424+ raise error
0 commit comments