##// END OF EJS Templates
update pylabtools test to use new print_figure
MinRK -
Show More
@@ -1,54 +1,54
1 """Tests for pylab tools module.
1 """Tests for pylab tools module.
2 """
2 """
3 #-----------------------------------------------------------------------------
3 #-----------------------------------------------------------------------------
4 # Copyright (c) 2011, the IPython Development Team.
4 # Copyright (c) 2011, the IPython Development Team.
5 #
5 #
6 # Distributed under the terms of the Modified BSD License.
6 # Distributed under the terms of the Modified BSD License.
7 #
7 #
8 # The full license is in the file COPYING.txt, distributed with this software.
8 # The full license is in the file COPYING.txt, distributed with this software.
9 #-----------------------------------------------------------------------------
9 #-----------------------------------------------------------------------------
10
10
11 #-----------------------------------------------------------------------------
11 #-----------------------------------------------------------------------------
12 # Imports
12 # Imports
13 #-----------------------------------------------------------------------------
13 #-----------------------------------------------------------------------------
14 from __future__ import print_function
14 from __future__ import print_function
15
15
16 # Stdlib imports
16 # Stdlib imports
17
17
18 # Third-party imports
18 # Third-party imports
19 import matplotlib; matplotlib.use('Agg')
19 import matplotlib; matplotlib.use('Agg')
20 import nose.tools as nt
20 import nose.tools as nt
21
21
22 from matplotlib import pyplot as plt
22 from matplotlib import pyplot as plt
23
23
24 # Our own imports
24 # Our own imports
25 from IPython.testing import decorators as dec
25 from IPython.testing import decorators as dec
26 from .. import pylabtools as pt
26 from .. import pylabtools as pt
27
27
28 #-----------------------------------------------------------------------------
28 #-----------------------------------------------------------------------------
29 # Globals and constants
29 # Globals and constants
30 #-----------------------------------------------------------------------------
30 #-----------------------------------------------------------------------------
31
31
32 #-----------------------------------------------------------------------------
32 #-----------------------------------------------------------------------------
33 # Local utilities
33 # Local utilities
34 #-----------------------------------------------------------------------------
34 #-----------------------------------------------------------------------------
35
35
36 #-----------------------------------------------------------------------------
36 #-----------------------------------------------------------------------------
37 # Classes and functions
37 # Classes and functions
38 #-----------------------------------------------------------------------------
38 #-----------------------------------------------------------------------------
39
39
40 @dec.parametric
40 @dec.parametric
41 def test_figure_to_svg():
41 def test_figure_to_svg():
42 # simple empty-figure test
42 # simple empty-figure test
43 fig = plt.figure()
43 fig = plt.figure()
44 yield nt.assert_equal(pt.figure_to_svg(fig), None)
44 yield nt.assert_equal(pt.print_figure(fig, 'svg'), None)
45
45
46 plt.close('all')
46 plt.close('all')
47
47
48 # simple check for at least svg-looking output
48 # simple check for at least svg-looking output
49 fig = plt.figure()
49 fig = plt.figure()
50 ax = fig.add_subplot(1,1,1)
50 ax = fig.add_subplot(1,1,1)
51 ax.plot([1,2,3])
51 ax.plot([1,2,3])
52 plt.draw()
52 plt.draw()
53 svg = pt.figure_to_svg(fig)[:100].lower()
53 svg = pt.print_figure(fig, 'svg')[:100].lower()
54 yield nt.assert_true('doctype svg' in svg)
54 yield nt.assert_true('doctype svg' in svg)
General Comments 0
You need to be logged in to leave comments. Login now