|
110 | 110 | r'$\left(X\right)_{a}^{b}$', # github issue 7615 |
111 | 111 | r'$\dfrac{\$100.00}{y}$', # github issue #1888 |
112 | 112 | ] |
| 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 | + r'$\sqrt[ab]{123}$', # github issue #8665 |
| 118 | +] |
113 | 119 |
|
114 | 120 | digits = "0123456789" |
115 | 121 | uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" |
|
165 | 171 | for set in chars: |
166 | 172 | font_tests.append(wrapper % set) |
167 | 173 |
|
168 | | -font_tests = list(filter(lambda x: x[1] is not None, enumerate(font_tests))) |
169 | | - |
170 | 174 |
|
171 | 175 | @pytest.fixture |
172 | | -def baseline_images(request, fontset, index): |
| 176 | +def baseline_images(request, fontset, index, text): |
| 177 | + if text is None: |
| 178 | + pytest.skip("test has been removed") |
173 | 179 | return ['%s_%s_%02d' % (request.param, fontset, index)] |
174 | 180 |
|
175 | 181 |
|
176 | | -cur_math_tests = list(filter(lambda x: x[1] is not None, enumerate(math_tests))) |
177 | | - |
178 | | - |
179 | | -@pytest.mark.parametrize('index, test', cur_math_tests, |
180 | | - ids=[str(index) for index, _ in cur_math_tests]) |
181 | | -@pytest.mark.parametrize('fontset', |
182 | | - ['cm', 'stix', 'stixsans', 'dejavusans', |
183 | | - 'dejavuserif']) |
| 182 | +@pytest.mark.parametrize( |
| 183 | + 'index, text', enumerate(math_tests), ids=range(len(math_tests))) |
| 184 | +@pytest.mark.parametrize( |
| 185 | + 'fontset', ['cm', 'stix', 'stixsans', 'dejavusans', 'dejavuserif']) |
184 | 186 | @pytest.mark.parametrize('baseline_images', ['mathtext'], indirect=True) |
185 | 187 | @image_comparison(baseline_images=None) |
186 | | -def test_mathtext_rendering(baseline_images, fontset, index, test): |
| 188 | +def test_mathtext_rendering(baseline_images, fontset, index, text): |
187 | 189 | mpl.rcParams['mathtext.fontset'] = fontset |
188 | 190 | fig = plt.figure(figsize=(5.25, 0.75)) |
189 | | - fig.text(0.5, 0.5, test, |
| 191 | + fig.text(0.5, 0.5, text, |
190 | 192 | horizontalalignment='center', verticalalignment='center') |
191 | 193 |
|
192 | 194 |
|
193 | | -@pytest.mark.parametrize('index, test', font_tests, |
194 | | - ids=[str(index) for index, _ in font_tests]) |
195 | | -@pytest.mark.parametrize('fontset', |
196 | | - ['cm', 'stix', 'stixsans', 'dejavusans', |
197 | | - 'dejavuserif']) |
| 195 | +@pytest.mark.parametrize('index, text', enumerate(lightweight_math_tests), |
| 196 | + ids=range(len(lightweight_math_tests))) |
| 197 | +@pytest.mark.parametrize('fontset', ['dejavusans']) |
| 198 | +@pytest.mark.parametrize('baseline_images', ['mathtext1'], indirect=True) |
| 199 | +@image_comparison(baseline_images=None, extensions=['png']) |
| 200 | +def test_mathtext_rendering_lightweight(baseline_images, fontset, index, text): |
| 201 | + fig = plt.figure(figsize=(5.25, 0.75)) |
| 202 | + fig.text(0.5, 0.5, text, math_fontfamily=fontset, |
| 203 | + horizontalalignment='center', verticalalignment='center') |
| 204 | + |
| 205 | + |
| 206 | +@pytest.mark.parametrize( |
| 207 | + 'index, text', enumerate(font_tests), ids=range(len(font_tests))) |
| 208 | +@pytest.mark.parametrize( |
| 209 | + 'fontset', ['cm', 'stix', 'stixsans', 'dejavusans', 'dejavuserif']) |
198 | 210 | @pytest.mark.parametrize('baseline_images', ['mathfont'], indirect=True) |
199 | 211 | @image_comparison(baseline_images=None, extensions=['png']) |
200 | | -def test_mathfont_rendering(baseline_images, fontset, index, test): |
| 212 | +def test_mathfont_rendering(baseline_images, fontset, index, text): |
201 | 213 | mpl.rcParams['mathtext.fontset'] = fontset |
202 | 214 | fig = plt.figure(figsize=(5.25, 0.75)) |
203 | | - fig.text(0.5, 0.5, test, |
| 215 | + fig.text(0.5, 0.5, text, |
204 | 216 | horizontalalignment='center', verticalalignment='center') |
205 | 217 |
|
206 | 218 |
|
|
0 commit comments