Debian Codegraph @

rpython/translator/c/test/test_standalone_print_function.py

raw symbols SCIP
1 """In which we test py3 print function syntax
2 (incompatible with py2 syntax in the same file)"""
3
4 from __future__ import print_function
5
6 from rpython.translator.c.test import test_standalone
7
8 setup_module = test_standalone.setup_module
9 teardown_module = test_standalone.teardown_module
10
11
12 class TestStandalonePrintFunction(test_standalone.StandaloneTestsVerified):
13
14 def test_print_function(self):
15 def entry_point(argv):
16 print("hello simpler world")
17 argv = argv[1:]
18 print("argument count:", len(argv))
19 print("arguments:", argv)
20 # with a space
21 print("argument lengths:", end=" ")
22 print([len(s) for s in argv])
23 # with no space
24 print("argument lengths:", end="")
25 print([len(s) for s in argv])
26 # strange ending
27 print("end", "is", end="\nstrange!\r\n")
28 return 0
29
30 t, cbuilder = self.compile(entry_point)
31 data = cbuilder.cmdexec("hi there")
32 assert data.startswith(
33 "hello simpler world\n"
34 "argument count: 2\n"
35 "arguments: [hi, there]\n"
36 "argument lengths: [2, 5]\n"
37 "argument lengths:[2, 5]\n"
38 "end is\nstrange!\n"
39 )
40 # NB. RPython has only str, not repr, so str() on a list of strings
41 # gives the strings unquoted in the list