Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9666324

Browse files
committed
Merge pull request matplotlib#2437 from mdboom/fix-randomly-failing-tests
Fix randomly failing tests
2 parents 42165c8 + 9eda53b commit 9666324

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/matplotlib/tests/__init__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
import difflib
55

6+
from matplotlib import rcParams, rcdefaults, use
7+
68

79
_multiprocess_can_split_ = True
810

@@ -12,6 +14,7 @@ def setup():
1214
# it during all of the tests.
1315
import locale
1416
import warnings
17+
from matplotlib.backends import backend_agg, backend_pdf, backend_svg
1518

1619
try:
1720
locale.setlocale(locale.LC_ALL, str('en_US.UTF-8'))
@@ -28,11 +31,17 @@ def setup():
2831
# These settings *must* be hardcoded for running the comparison
2932
# tests and are not necessarily the default values as specified in
3033
# rcsetup.py
31-
rcdefaults() # Start with all defaults
34+
rcdefaults() # Start with all defaults
3235
rcParams['font.family'] = 'Bitstream Vera Sans'
3336
rcParams['text.hinting'] = False
3437
rcParams['text.hinting_factor'] = 8
3538

39+
# Clear the font caches. Otherwise, the hinting mode can travel
40+
# from one test to another.
41+
backend_agg.RendererAgg._fontd.clear()
42+
backend_pdf.RendererPdf.truetype_font_cache.clear()
43+
backend_svg.RendererSVG.fontd.clear()
44+
3645

3746
def assert_str_equal(reference_str, test_str,
3847
format_str='String {str1} and {str2} do not match:\n{differences}'):

0 commit comments

Comments
 (0)