1 from Cython
.TestUtils
import CythonTest
3 class TestCodeWriter(CythonTest
):
4 # CythonTest uses the CodeWriter heavily, so do some checking by
5 # roundtripping Cython code through the test framework.
7 # Note that this test is dependant upon the normal Cython parser
8 # to generate the input trees to the CodeWriter. This save *a lot*
9 # of time; better to spend that time writing other tests than perfecting
12 # Whitespace is very significant in this process:
13 # - always newline on new block (!)
15 # - 1 space around every operator
18 self
.assertCode(codestr
, self
.fragment(codestr
).root
)
28 self
.t(u
"if x:\n pass")
30 def test_ifelifelse(self
):
36 elif z + 34 ** 34 - 2:
46 def f(x = 34, y = 54, z):
50 def test_longness_and_signedness(self
):
51 self
.t(u
"def f(unsigned long long long long long int y):\n pass")
53 def test_signed_short(self
):
54 self
.t(u
"def f(signed short int y):\n pass")
56 def test_typed_args(self
):
57 self
.t(u
"def f(int x, unsigned long int y):\n pass")
59 def test_cdef_var(self
):
62 cdef int hello = 4, x = 3, y, z
65 def test_for_loop(self
):
67 for x, y, z in f(g(h(34) * 2) + 23):
73 def test_inplace_assignment(self
):
76 def test_attribute(self
):
79 if __name__
== "__main__":