Debian Codegraph @

pypy/interpreter/test/test_targetpypy.py

raw symbols SCIP
1 from pypy.goal.targetpypystandalone import get_entry_point, create_entry_point
2 from pypy.config.pypyoption import get_pypy_config
3 from rpython.rtyper.lltypesystem import rffi, lltype
4
5 class TestTargetPyPy(object):
6 def test_run(self):
7 config = get_pypy_config(translating=False)
8 entry_point = get_entry_point(config)[0]
9 entry_point(['pypy3-c' , '-S', '-c', 'print(3)'])
10
11 def test_execute_source(space):
12 _, d = create_entry_point(space, None)
13 execute_source = d['pypy_execute_source']
14 lls = rffi.str2charp("import sys; sys.modules['xyz'] = 3")
15 res = execute_source(lls)
16 lltype.free(lls, flavor='raw')
17 assert lltype.typeOf(res) == rffi.INT
18 assert rffi.cast(lltype.Signed, res) == 0
19 x = space.int_w(space.getitem(space.getattr(space.builtin_modules['sys'],
20 space.wrap('modules')),
21 space.wrap('xyz')))
22 assert x == 3
23 lls = rffi.str2charp("sys # should give a NameError")
24 execute_source(lls)
25 lltype.free(lls, flavor='raw')
26 # did not crash - the same globals
27 pypy_setup_home = d['pypy_setup_home']
28 lls = rffi.str2charp(__file__)
29 res = pypy_setup_home(lls, rffi.cast(rffi.INT, 1))
30 assert lltype.typeOf(res) == rffi.INT
31 assert rffi.cast(lltype.Signed, res) == 0
32 lltype.free(lls, flavor='raw')