##// END OF EJS Templates
skip sympy tests if sympy not installed
Paul Ivanov -
Show More
@@ -15,13 +15,19 b' Authors:'
15 15 #-----------------------------------------------------------------------------
16 16
17 17 from IPython.lib.latextools import latex_to_png
18 from IPython.testing import decorators as dec
19
20 try:
21 from sympy import pretty, latex
22 except ImportError:
23 pass
18 24
19 from sympy import pretty, latex
20 25
21 26 #-----------------------------------------------------------------------------
22 27 # Definitions of magic functions for use with IPython
23 28 #-----------------------------------------------------------------------------
24 29
30 @dec.skipif_not_sympy
25 31 def print_basic_unicode(o, p, cycle):
26 32 """A function to pretty print sympy Basic objects."""
27 33 if cycle:
@@ -32,6 +38,7 b' def print_basic_unicode(o, p, cycle):'
32 38 p.text(out)
33 39
34 40
41 @dec.skipif_not_sympy
35 42 def print_png(o):
36 43 """A funciton to display sympy expression using LaTex -> PNG."""
37 44 s = latex(o, mode='inline')
@@ -44,7 +51,7 b' def print_png(o):'
44 51
45 52 _loaded = False
46 53
47
54 @dec.skipif_not_sympy
48 55 def load_ipython_extension(ip):
49 56 """Load the extension in IPython."""
50 57 global _loaded
@@ -274,19 +274,19 b' def onlyif(condition, msg):'
274 274
275 275 #-----------------------------------------------------------------------------
276 276 # Utility functions for decorators
277 def numpy_not_available():
278 """Can numpy be imported? Returns true if numpy does NOT import.
277 def module_not_available(module):
278 """Can module be imported? Returns true if module does NOT import.
279 279
280 This is used to make a decorator to skip tests that require numpy to be
280 This is used to make a decorator to skip tests that require module to be
281 281 available, but delay the 'import numpy' to test execution time.
282 282 """
283 283 try:
284 import numpy
285 np_not_avail = False
284 mod = __import__(module)
285 mod_not_avail = False
286 286 except ImportError:
287 np_not_avail = True
287 mod_not_avail = True
288 288
289 return np_not_avail
289 yield mod_not_avail
290 290
291 291 #-----------------------------------------------------------------------------
292 292 # Decorators for public use
@@ -315,9 +315,11 b" skip_if_not_osx = skipif(sys.platform != 'darwin',"
315 315 "This test only runs under OSX")
316 316
317 317 # Other skip decorators
318 skipif_not_numpy = skipif(numpy_not_available,"This test requires numpy")
318 skipif_not_numpy = skipif(module_not_available('numpy'),"This test requires numpy")
319 319
320 skip_known_failure = skip('This test is known to fail')
320 skipif_not_sympy = skipif(module_not_available('sympy'),"This test requires sympy")
321
322 skip_known_failure = knownfailureif(True,'This test is known to fail')
321 323
322 324 # A null 'decorator', useful to make more readable code that needs to pick
323 325 # between different decorators based on OS or other conditions
General Comments 0
You need to be logged in to leave comments. Login now