Skip to content

Commit d6687ce

Browse files
committed
Add machinery for png-only, single-font mathtext tests.
(For the sqrt test added below, each font adds ~2k to the size of the baseline image file.)
1 parent 2971563 commit d6687ce

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lib/matplotlib/tests/test_mathtext.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@
110110
r'$\left(X\right)_{a}^{b}$', # github issue 7615
111111
r'$\dfrac{\$100.00}{y}$', # github issue #1888
112112
]
113+
# 'Lightweight' tests test only a single fontset (dejavusans, which is the
114+
# default) and only png outputs, in order to minimize the size of baseline
115+
# images.
116+
lightweight_math_tests = [
117+
]
113118

114119
digits = "0123456789"
115120
uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
@@ -186,6 +191,17 @@ def test_mathtext_rendering(baseline_images, fontset, index, text):
186191
horizontalalignment='center', verticalalignment='center')
187192

188193

194+
@pytest.mark.parametrize('index, text', enumerate(lightweight_math_tests),
195+
ids=range(len(lightweight_math_tests)))
196+
@pytest.mark.parametrize('fontset', ['dejavusans'])
197+
@pytest.mark.parametrize('baseline_images', ['mathtext1'], indirect=True)
198+
@image_comparison(baseline_images=None, extensions=['png'])
199+
def test_mathtext_rendering_lightweight(baseline_images, fontset, index, text):
200+
fig = plt.figure(figsize=(5.25, 0.75))
201+
fig.text(0.5, 0.5, text, math_fontfamily=fontset,
202+
horizontalalignment='center', verticalalignment='center')
203+
204+
189205
@pytest.mark.parametrize(
190206
'index, text', enumerate(font_tests), ids=range(len(font_tests)))
191207
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)