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

Skip to content

Commit 38ad22d

Browse files
committed
Make classic testing work correctly
Fix failures in matplotlib#5416
1 parent 5ac32f3 commit 38ad22d

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

lib/matplotlib/testing/decorators.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from matplotlib import ticker
2323
from matplotlib import pyplot as plt
2424
from matplotlib import ft2font
25+
from matplotlib import rcParams
2526
from matplotlib.testing.noseclasses import KnownFailureTest, \
2627
KnownFailureDidNotFailTest, ImageComparisonFailure
2728
from matplotlib.testing.compare import comparable_formats, compare_images, \
@@ -138,6 +139,7 @@ def check_freetype_version(ver):
138139
class ImageComparisonTest(CleanupTest):
139140
@classmethod
140141
def setup_class(cls):
142+
CleanupTest.setup_class()
141143
cls._initial_settings = mpl.rcParams.copy()
142144
try:
143145
matplotlib.style.use(cls._style)
@@ -146,11 +148,8 @@ def setup_class(cls):
146148
mpl.rcParams.clear()
147149
mpl.rcParams.update(cls._initial_settings)
148150
raise
149-
# Because the setup of a CleanupTest might involve
150-
# modifying a few rcparams, this setup should come
151-
# last prior to running the image test.
152-
CleanupTest.setup_class()
153151
cls.original_settings = cls._initial_settings
152+
matplotlib.tests.set_font_settings_for_testing()
154153
cls._func()
155154

156155
@classmethod

lib/matplotlib/tests/__init__.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
'test data.')
2323

2424

25+
def set_font_settings_for_testing():
26+
rcParams['font.family'] = 'DejaVu Sans'
27+
rcParams['text.hinting'] = False
28+
rcParams['text.hinting_factor'] = 8
29+
30+
2531
def setup():
2632
# The baseline images are created in this locale, so we should use
2733
# it during all of the tests.
@@ -45,9 +51,8 @@ def setup():
4551
# tests and are not necessarily the default values as specified in
4652
# rcsetup.py
4753
rcdefaults() # Start with all defaults
48-
rcParams['font.family'] = 'DejaVu Sans'
49-
rcParams['text.hinting'] = False
50-
rcParams['text.hinting_factor'] = 8
54+
55+
set_font_settings_for_testing()
5156

5257

5358
def assert_str_equal(reference_str, test_str,

0 commit comments

Comments
 (0)