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

Skip to content

Commit 49ad267

Browse files
committed
Fix unicode won test
1 parent 0122faf commit 49ad267

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

lib/matplotlib/tests/test_backend_svg.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -212,20 +212,22 @@ def psfont(*args, **kwargs):
212212

213213
@needs_tex
214214
def test_unicode_won():
215-
from pylab import rcParams, plot, ylabel, savefig
216-
rcParams.update({'text.usetex': True, 'text.latex.unicode': True})
215+
matplotlib.rcParams['text.usetex'] = True
216+
matplotlib.rcParams['text.latex.unicode'] = True
217217

218-
plot(1, 1)
219-
ylabel(r'\textwon')
218+
plt.figure()
219+
plt.plot(1, 1)
220+
plt.ylabel(r'\textwon')
220221

221222
fd = BytesIO()
222-
savefig(fd, format='svg')
223+
plt.savefig(fd, format='svg')
223224
fd.seek(0)
224225
buf = fd.read().decode()
225226
fd.close()
226227

227-
won_id = 'Computer_Modern_Sans_Serif-142'
228-
def_regex = re.compile(r'<path d=(.|\s)*?id="{0}"/>'.format(won_id))
229-
use_regex = re.compile(r'<use[^/>]*? xlink:href="#{0}"/>'.format(won_id))
230-
assertTrue(bool(def_regex.search(buf)))
231-
assertTrue(bool(use_regex.search(buf)))
228+
won_id = 'Computer_Modern_Roman-142'
229+
expected_def = 'id="{0}"'.format(won_id)
230+
expected_ref = 'xlink:href="#{0}"'.format(won_id)
231+
print(buf)
232+
assert expected_def in buf
233+
assert expected_ref in buf

0 commit comments

Comments
 (0)