From 9eda53b2fc1bd3eba48e7e37f9829794ab416b12 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Wed, 18 Sep 2013 14:59:44 -0400 Subject: [PATCH] Clear the font caches on every test. This should prevent problems where setting font properties will leak over into another test. --- lib/matplotlib/tests/__init__.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/tests/__init__.py b/lib/matplotlib/tests/__init__.py index a1b5b29b0be2..7753f603487b 100644 --- a/lib/matplotlib/tests/__init__.py +++ b/lib/matplotlib/tests/__init__.py @@ -3,6 +3,8 @@ import difflib +from matplotlib import rcParams, rcdefaults, use + _multiprocess_can_split_ = True @@ -12,6 +14,7 @@ def setup(): # it during all of the tests. import locale import warnings + from matplotlib.backends import backend_agg, backend_pdf, backend_svg try: locale.setlocale(locale.LC_ALL, str('en_US.UTF-8')) @@ -28,11 +31,17 @@ def setup(): # These settings *must* be hardcoded for running the comparison # tests and are not necessarily the default values as specified in # rcsetup.py - rcdefaults() # Start with all defaults + rcdefaults() # Start with all defaults rcParams['font.family'] = 'Bitstream Vera Sans' rcParams['text.hinting'] = False rcParams['text.hinting_factor'] = 8 + # Clear the font caches. Otherwise, the hinting mode can travel + # from one test to another. + backend_agg.RendererAgg._fontd.clear() + backend_pdf.RendererPdf.truetype_font_cache.clear() + backend_svg.RendererSVG.fontd.clear() + def assert_str_equal(reference_str, test_str, format_str='String {str1} and {str2} do not match:\n{differences}'):