##// END OF EJS Templates
Using better approach for skipping test if Cython no pres.
Brian Granger -
Show More
@@ -1,45 +1,45 b''
1 1 # -*- coding: utf-8 -*-
2 2 """Tests for the Cython magics extension."""
3 3
4 4 import os
5 5 import nose.tools as nt
6 6
7 7
8 8 code = """def f(x):
9 9 return 2*x
10 10 """
11 11
12 12 try:
13 13 import Cython
14 14 except:
15 pass
16 else:
17 def setup():
18 ip = get_ipython()
19 ip.extension_manager.load_extension('cythonmagic')
20
21 def test_cython_inline():
22 ip = get_ipython()
23 ip.ex('a=10; b=20')
24 result = ip.run_cell_magic('cython_inline','','return a+b')
25 nt.assert_equals(result, 30)
26
27 def test_cython_pyximport():
28 module_name = '_test_cython_pyximport'
29 ip = get_ipython()
30 ip.run_cell_magic('cython_pyximport', module_name, code)
31 ip.ex('g = f(10)')
32 nt.assert_equals(ip.user_ns['g'], 20.0)
33 try:
34 os.remove(module_name+'.pyx')
35 except OSError:
36 pass
37
38 def test_cython():
39 ip = get_ipython()
40 ip.run_cell_magic('cython', '', code)
41 ip.ex('g = f(10)')
42 nt.assert_equals(ip.user_ns['g'], 20.0)
15 __test__ = False
16
17 def setup():
18 ip = get_ipython()
19 ip.extension_manager.load_extension('cythonmagic')
20
21 def test_cython_inline():
22 ip = get_ipython()
23 ip.ex('a=10; b=20')
24 result = ip.run_cell_magic('cython_inline','','return a+b')
25 nt.assert_equals(result, 30)
26
27 def test_cython_pyximport():
28 module_name = '_test_cython_pyximport'
29 ip = get_ipython()
30 ip.run_cell_magic('cython_pyximport', module_name, code)
31 ip.ex('g = f(10)')
32 nt.assert_equals(ip.user_ns['g'], 20.0)
33 try:
34 os.remove(module_name+'.pyx')
35 except OSError:
36 pass
37
38 def test_cython():
39 ip = get_ipython()
40 ip.run_cell_magic('cython', '', code)
41 ip.ex('g = f(10)')
42 nt.assert_equals(ip.user_ns['g'], 20.0)
43 43
44 44
45 45
General Comments 0
You need to be logged in to leave comments. Login now