Debian Codegraph @

tests/run/common_utility_types.srctree

raw
1 PYTHON setup.py build_ext --inplace
2 PYTHON -c "import runner"
3
4 ######## setup.py ########
5
6 from Cython.Build.Dependencies import cythonize
7
8 from distutils.core import setup
9
10 setup(
11 ext_modules = cythonize("*.pyx"),
12 )
13
14 ######## a.pyx ########
15
16 # cython: binding=True
17
18 def funcA():
19 return
20
21 ######## b.pyx ########
22
23 # cython: binding=True
24
25 def funcB():
26 return
27
28 ######## runner.py ########
29
30 print("importing...")
31 import a, b
32 print(type(a.funcA))
33
34 assert type(a.funcA).__name__.endswith('cython_function_or_method')
35 assert type(a.funcA) is type(b.funcB)
36
37 assert a.funcA.func_globals is a.__dict__
38 assert b.funcB.func_globals is b.__dict__
39
40 # Test that it's possible to look up the name of the class
41 from sys import modules
42 cy_modules = [ mod for n, mod in modules.items() if n.startswith("_cython_") ]
43 # In principle it's possible to have "_cython_" internal modules for multiple
44 # different versions of Cython. However, since this is run in an end-to-end test
45 # with a very short list of imports it should not happen here.
46 assert(len(cy_modules)==1)
47 mod = cy_modules[0]
48
49 assert '.' not in type(a.funcA).__name__
50 func_t = getattr(mod, type(a.funcA).__name__)
51 assert func_t is type(a.funcA)