Debian Codegraph @

tests/run/unicode_imports.srctree

raw
1 # -*- coding: utf-8 -*-
2 # tag: py3, pep489
3
4 PYTHON setup.py build_ext --inplace
5 PYTHON -m mydoctest
6
7 ########### mydoctest.py #######
8
9 import doctest
10 import from_py
11 val = doctest.testmod(from_py)[0]
12 import from_cy
13 val += doctest.testmod(from_cy)[0]
14
15 exit(val)
16
17 ########### setup.py ########
18
19 # -*- coding: utf-8 -*-
20
21 from __future__ import unicode_literals
22
23 from Cython.Build import cythonize
24
25 files = ["mymoð.pyx", "from_cy.pyx", "测试.py" ]
26
27 modules = cythonize(files)
28
29 from distutils.core import setup
30
31 setup(
32 ext_modules = modules
33 )
34
35 ############ mymoð.pyx #########
36
37 def f():
38 return True
39
40 cdef public api void cdef_func():
41 pass
42
43 ############ pxd_moð.pxd ##########
44
45 cdef struct S:
46 int x
47
48 cdef public api void cdef_func() # just to test generation of headers
49
50 ############ 测试.py #############
51
52 def g():
53 return 1
54
55 ############ from_py.py #########
56
57 # -*- coding: utf-8 -*-
58
59 import mymoð
60 from mymoð import f
61 import 测试
62
63 __doc__ = """
64 >>> mymoð.f()
65 True
66 >>> f()
67 True
68 >>> 测试.g()
69 1
70 """
71
72 ######### from_cy.pyx ##########
73
74 # -*- coding: utf-8 -*-
75
76 import mymoð
77
78 from mymoð import f
79 import 测试
80
81 cimport pxd_moð
82 from pxd_moð cimport S
83
84
85 def test_imported():
86 """
87 >>> test_imported()
88 True
89 """
90 return mymoð.f() and f() # True and True
91
92
93 def test_imported2():
94 """
95 >>> test_imported2()
96 1
97 """
98 return 测试.g()
99
100
101 def test_cimported():
102 """
103 >>> test_cimported()
104 3
105 """
106 cdef pxd_moð.S v1
107 v1.x = 1
108 cdef S v2
109 v2.x = 2
110 return v1.x + v2.x
111