##// END OF EJS Templates
Improve test mocking to actually capture failure mode.
Ryan May -
Show More
@@ -68,8 +68,17 b' class TestPylabSwitch(object):'
68 pylab_gui_select = None
68 pylab_gui_select = None
69
69
70 def setup(self):
70 def setup(self):
71 import matplotlib
72 def act_mpl(backend):
73 matplotlib.rcParams['backend'] = backend
74
75 # Save rcParams since they get modified
76 self._saved_rcParams = matplotlib.rcParams
77 matplotlib.rcParams = dict(backend='Qt4Agg')
78
79 # Mock out functions
71 self._save_am = pt.activate_matplotlib
80 self._save_am = pt.activate_matplotlib
72 pt.activate_matplotlib = lambda *a,**kw:None
81 pt.activate_matplotlib = act_mpl
73 self._save_ip = pt.import_pylab
82 self._save_ip = pt.import_pylab
74 pt.import_pylab = lambda *a,**kw:None
83 pt.import_pylab = lambda *a,**kw:None
75 self._save_cis = pt.configure_inline_support
84 self._save_cis = pt.configure_inline_support
@@ -79,10 +88,12 b' class TestPylabSwitch(object):'
79 pt.activate_matplotlib = self._save_am
88 pt.activate_matplotlib = self._save_am
80 pt.import_pylab = self._save_ip
89 pt.import_pylab = self._save_ip
81 pt.configure_inline_support = self._save_cis
90 pt.configure_inline_support = self._save_cis
91 import matplotlib
92 matplotlib.rcParams = self._saved_rcParams
82
93
83 def test_qt(self):
94 def test_qt(self):
84 s = self.Shell()
95 s = self.Shell()
85 gui = pt.pylab_activate(dict(), 'qt', False, s)
96 gui = pt.pylab_activate(dict(), None, False, s)
86 nt.assert_equal(gui, 'qt')
97 nt.assert_equal(gui, 'qt')
87 nt.assert_equal(s.pylab_gui_select, 'qt')
98 nt.assert_equal(s.pylab_gui_select, 'qt')
88
99
@@ -90,7 +101,7 b' class TestPylabSwitch(object):'
90 nt.assert_equal(gui, 'inline')
101 nt.assert_equal(gui, 'inline')
91 nt.assert_equal(s.pylab_gui_select, 'qt')
102 nt.assert_equal(s.pylab_gui_select, 'qt')
92
103
93 gui = pt.pylab_activate(dict(), None, False, s)
104 gui = pt.pylab_activate(dict(), 'qt', False, s)
94 nt.assert_equal(gui, 'qt')
105 nt.assert_equal(gui, 'qt')
95 nt.assert_equal(s.pylab_gui_select, 'qt')
106 nt.assert_equal(s.pylab_gui_select, 'qt')
96
107
General Comments 0
You need to be logged in to leave comments. Login now