##// 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 68 pylab_gui_select = None
69 69
70 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 80 self._save_am = pt.activate_matplotlib
72 pt.activate_matplotlib = lambda *a,**kw:None
81 pt.activate_matplotlib = act_mpl
73 82 self._save_ip = pt.import_pylab
74 83 pt.import_pylab = lambda *a,**kw:None
75 84 self._save_cis = pt.configure_inline_support
@@ -79,10 +88,12 b' class TestPylabSwitch(object):'
79 88 pt.activate_matplotlib = self._save_am
80 89 pt.import_pylab = self._save_ip
81 90 pt.configure_inline_support = self._save_cis
91 import matplotlib
92 matplotlib.rcParams = self._saved_rcParams
82 93
83 94 def test_qt(self):
84 95 s = self.Shell()
85 gui = pt.pylab_activate(dict(), 'qt', False, s)
96 gui = pt.pylab_activate(dict(), None, False, s)
86 97 nt.assert_equal(gui, 'qt')
87 98 nt.assert_equal(s.pylab_gui_select, 'qt')
88 99
@@ -90,7 +101,7 b' class TestPylabSwitch(object):'
90 101 nt.assert_equal(gui, 'inline')
91 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 105 nt.assert_equal(gui, 'qt')
95 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