##// END OF EJS Templates
Skip tests that require X, when importing pylab results in RuntimeError....
Thomas Spura -
Show More
@@ -15,6 +15,14 import re
15 from IPython.lib import irunner
15 from IPython.lib import irunner
16 from IPython.testing import decorators
16 from IPython.testing import decorators
17
17
18 def pylab_not_importable():
19 """Test if importing pylab fails with RuntimeError (true when having no display)"""
20 try:
21 import pylab
22 return False
23 except RuntimeError:
24 return True
25
18 # Testing code begins
26 # Testing code begins
19 class RunnerTestCase(unittest.TestCase):
27 class RunnerTestCase(unittest.TestCase):
20
28
@@ -57,6 +65,7 class RunnerTestCase(unittest.TestCase):
57 self.assert_(mismatch==0,'Number of mismatched lines: %s' %
65 self.assert_(mismatch==0,'Number of mismatched lines: %s' %
58 mismatch)
66 mismatch)
59
67
68 @decorators.skipif(pylab_not_importable, "Likely a run without X.")
60 @decorators.skipif_not_matplotlib
69 @decorators.skipif_not_matplotlib
61 def test_pylab_import_all_enabled(self):
70 def test_pylab_import_all_enabled(self):
62 "Verify that plot is available when pylab_import_all = True"
71 "Verify that plot is available when pylab_import_all = True"
@@ -82,6 +91,7 Out\[6\]: True
82 runner = irunner.IPythonRunner(out=self.out)
91 runner = irunner.IPythonRunner(out=self.out)
83 self._test_runner(runner,source,output)
92 self._test_runner(runner,source,output)
84
93
94 @decorators.skipif(pylab_not_importable, "Likely a run without X.")
85 @decorators.skipif_not_matplotlib
95 @decorators.skipif_not_matplotlib
86 def test_pylab_import_all_disabled(self):
96 def test_pylab_import_all_disabled(self):
87 "Verify that plot is not available when pylab_import_all = False"
97 "Verify that plot is not available when pylab_import_all = False"
General Comments 0
You need to be logged in to leave comments. Login now