6
# show behaviour in Python mode
7
PYTHON -m doctest test0.py
8
PYTHON -m doctest test1.py
9
PYTHON -m doctest test2.py
11
PYTHON setup.py build_ext --inplace
13
PYTHON -c "import doctest; import test0 as m; exit(doctest.testmod(m)[0])"
14
PYTHON -c "import doctest; import test1 as m; exit(doctest.testmod(m)[0])"
15
PYTHON -c "import doctest; import test2 as m; exit(doctest.testmod(m)[0])"
17
########## setup.py #########
19
from Cython.Build.Dependencies import cythonize
20
from distutils.core import setup
23
ext_modules = cythonize("test*.py"),
26
######### build_tests.py ########
27
# -*- coding: utf-8 -*-
28
from __future__ import unicode_literals
31
# a few pairs of unicode strings that should be equivalent after normalization
32
string_pairs = [("fi", "fi"), # ligature and two letters
33
("a\u0301", '\u00e1'), # a with acute accent with combining character or as 1 character
34
("α\u0334\u0362", "α\u0362\u0334") # alpha with a pair of combining characters
35
# in a different order. No single character to normalize to
38
# Show that the pairs genuinely aren't equal before normalization
39
for sp in string_pairs:
41
assert unicodedata.normalize('NFKC', sp[0]) == unicodedata.normalize('NFKC', sp[1])
43
# some code that accesses the identifiers through the two different names
59
>>> pass_through(True)
76
for idx, (code, strings) in enumerate(zip(example_code, string_pairs)):
77
with open("test{0}.py".format(idx), "w", encoding="utf8") as f:
78
code = code.format(*strings)
79
f.write("# -*- coding: utf-8 -*-\n")