##// END OF EJS Templates
Add test for external library linking.
Fernando Perez -
Show More
@@ -15,19 +15,21 b' try:'
15 except:
15 except:
16 __test__ = False
16 __test__ = False
17
17
18 ip = get_ipython()
19
20
18 def setup():
21 def setup():
19 ip = get_ipython()
20 ip.extension_manager.load_extension('cythonmagic')
22 ip.extension_manager.load_extension('cythonmagic')
21
23
24
22 def test_cython_inline():
25 def test_cython_inline():
23 ip = get_ipython()
24 ip.ex('a=10; b=20')
26 ip.ex('a=10; b=20')
25 result = ip.run_cell_magic('cython_inline','','return a+b')
27 result = ip.run_cell_magic('cython_inline','','return a+b')
26 nt.assert_equals(result, 30)
28 nt.assert_equals(result, 30)
27
29
30
28 def test_cython_pyximport():
31 def test_cython_pyximport():
29 module_name = '_test_cython_pyximport'
32 module_name = '_test_cython_pyximport'
30 ip = get_ipython()
31 ip.run_cell_magic('cython_pyximport', module_name, code)
33 ip.run_cell_magic('cython_pyximport', module_name, code)
32 ip.ex('g = f(10)')
34 ip.ex('g = f(10)')
33 nt.assert_equals(ip.user_ns['g'], 20.0)
35 nt.assert_equals(ip.user_ns['g'], 20.0)
@@ -36,12 +38,19 b' def test_cython_pyximport():'
36 except OSError:
38 except OSError:
37 pass
39 pass
38
40
41
39 def test_cython():
42 def test_cython():
40 ip = get_ipython()
41 ip.run_cell_magic('cython', '', code)
43 ip.run_cell_magic('cython', '', code)
42 ip.ex('g = f(10)')
44 ip.ex('g = f(10)')
43 nt.assert_equals(ip.user_ns['g'], 20.0)
45 nt.assert_equals(ip.user_ns['g'], 20.0)
44
46
45
47
46
48 def test_extlibs():
47
49 code = py3compat.str_to_unicode("""
50 from libc.math cimport sin
51 x = sin(0.0)
52 """)
53 ip.user_ns['x'] = 1
54 ip.run_cell_magic('cython', '-l m', code)
55 nt.assert_equals(ip.user_ns['x'], 0)
56
General Comments 0
You need to be logged in to leave comments. Login now