|
|
@@ -119,14 +119,15 @@ def test_bold_font_output_with_none_fonttype(): |
|
|
ax.set_title('bold-title', fontweight='bold')
|
|
|
|
|
|
|
|
|
-def _test_determinism(filename):
|
|
|
+def _test_determinism_save(filename, usetex):
|
|
|
# This function is mostly copy&paste from "def test_visibility"
|
|
|
# To require no GUI, we use Figure and FigureCanvasSVG
|
|
|
# instead of plt.figure and fig.savefig
|
|
|
from matplotlib.figure import Figure
|
|
|
from matplotlib.backends.backend_svg import FigureCanvasSVG
|
|
|
from matplotlib import rc
|
|
|
rc('svg', hashsalt='asdf')
|
|
|
+ rc('text', usetex=usetex)
|
|
|
|
|
|
fig = Figure()
|
|
|
ax = fig.add_subplot(111)
|
|
|
@@ -138,12 +139,14 @@ def _test_determinism(filename): |
|
|
a, b, c = ax.errorbar(x, y, yerr=yerr, fmt='ko')
|
|
|
for artist in b:
|
|
|
artist.set_visible(False)
|
|
|
+ ax.set_title('A string $1+2+\sigma$')
|
|
|
+ ax.set_xlabel('A string $1+2+\sigma$')
|
|
|
+ ax.set_ylabel('A string $1+2+\sigma$')
|
|
|
|
|
|
FigureCanvasSVG(fig).print_svg(filename)
|
|
|
|
|
|
|
|
|
-@cleanup
|
|
|
-def test_determinism():
|
|
|
+def _test_determinism(filename, usetex):
|
|
|
import os
|
|
|
import sys
|
|
|
from subprocess import check_call
|
|
|
@@ -154,15 +157,27 @@ def test_determinism(): |
|
|
'import matplotlib; '
|
|
|
'matplotlib.use("svg"); '
|
|
|
'from matplotlib.tests.test_backend_svg '
|
|
|
- 'import _test_determinism;'
|
|
|
- '_test_determinism("determinism.svg")'])
|
|
|
- with open('determinism.svg', 'rb') as fd:
|
|
|
+ 'import _test_determinism_save;'
|
|
|
+ '_test_determinism_save(%r, %r)' % (filename, usetex)])
|
|
|
+ with open(filename, 'rb') as fd:
|
|
|
plots.append(fd.read())
|
|
|
- os.unlink('determinism.svg')
|
|
|
+ os.unlink(filename)
|
|
|
for p in plots[1:]:
|
|
|
assert_equal(p, plots[0])
|
|
|
|
|
|
|
|
|
+@cleanup
|
|
|
+def test_determinism_notex():
|
|
|
+ # unique filename to allow for parallel testing
|
|
|
+ _test_determinism('determinism_notex.svg', usetex=False)
|
|
|
+
|
|
|
+
|
|
|
+@cleanup
|
|
|
+def test_determinism_tex():
|
|
|
+ # unique filename to allow for parallel testing
|
|
|
+ _test_determinism('determinism_tex.svg', usetex=True)
|
|
|
+
|
|
|
+
|
|
|
if __name__ == '__main__':
|
|
|
import nose
|
|
|
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)
|