codekingpro/portable-devtools
115k
1import platform
2
3import pytest
4
5from numpy.testing import IS_64BIT
6
7from . import util
8
9
10@pytest.mark.skipif(
11 platform.system() == "Darwin",
12 reason="Prone to error when run with numpy/f2py/tests on mac os, "
13 "but not when run in isolation",
14)
15@pytest.mark.skipif(
16 not IS_64BIT, reason="32-bit builds are buggy"
17)
18class TestMultiline(util.F2PyTest):
19 suffix = ".pyf"
20 module_name = "multiline"
21 code = f"""
22python module {module_name}
23 usercode '''
24void foo(int* x) {{
25 char dummy = ';';
26 *x = 42;
27}}
28'''
29 interface
30 subroutine foo(x)
31 intent(c) foo
32 integer intent(out) :: x
33 end subroutine foo
34 end interface
35end python module {module_name}
36 """
37
38 def test_multiline(self):
39 assert self.module.foo() == 42
40
41
42@pytest.mark.skipif(
43 platform.system() == "Darwin",
44 reason="Prone to error when run with numpy/f2py/tests on mac os, "
45 "but not when run in isolation",
46)
47@pytest.mark.skipif(
48 not IS_64BIT, reason="32-bit builds are buggy"
49)
50@pytest.mark.slow
51class TestCallstatement(util.F2PyTest):
52 suffix = ".pyf"
53 module_name = "callstatement"
54 code = f"""
55python module {module_name}
56 usercode '''
57void foo(int* x) {{
58}}
59'''
60 interface
61 subroutine foo(x)
62 intent(c) foo
63 integer intent(out) :: x
64 callprotoargument int*
65 callstatement {{ &
66 ; &
67 x = 42; &
68 }}
69 end subroutine foo
70 end interface
71end python module {module_name}
72 """
73
74 def test_callstatement(self):
75 assert self.module.foo() == 42
76 