本文整理汇总了Python中pypy.interpreter.gateway.app2interp_temp函数的典型用法代码示例。如果您正苦于以下问题:Python app2interp_temp函数的具体用法?Python app2interp_temp怎么用?Python app2interp_temp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了app2interp_temp函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_app2interp_future
def test_app2interp_future(self):
w = self.space.wrap
def app_g3(a, b):
print(end='')
return a / b
g3 = gateway.app2interp_temp(app_g3)
assert self.space.eq_w(g3(self.space, w(1), w(4),), w(0.25))
示例2: test_app2interp2
def test_app2interp2(self):
"""same but using transformed code"""
w = self.space.wrap
def noapp_g3(a, b):
return a+b
g3 = gateway.app2interp_temp(noapp_g3, gateway.applevelinterp_temp)
assert self.space.eq_w(g3(self.space, w('foo'), w('bar')), w('foobar'))
示例3: perform_trace
def perform_trace(self, app_func):
tspace = self.space
func_gw = gateway.app2interp_temp(app_func)
func = func_gw.get_function(tspace)
tspace.settrace()
tspace.call_function(tspace.wrap(func))
res = tspace.getresult()
return res
示例4: execute
def execute(self, target, *args):
assert not args
if option.runappdirect:
return target(*args)
space = target.im_self.space
func = app2interp_temp(target.im_func)
w_instance = self.parent.w_instance
self.execute_appex(space, func, space, w_instance)
示例5: test_app2interp1
def test_app2interp1(self):
w = self.space.wrap
def noapp_g3(a, b):
return a + b
g3 = gateway.app2interp_temp(noapp_g3, gateway.applevel_temp)
assert self.space.eq_w(g3(self.space, w("foo"), w("bar")), w("foobar"))
示例6: test_app2interp
def test_app2interp(self):
w = self.space.wrap
def app_g3(a, b):
return a + b
g3 = gateway.app2interp_temp(app_g3)
assert self.space.eq_w(g3(self.space, w("foo"), w("bar")), w("foobar"))
示例7: runtest
def runtest(self):
target = self.obj
if option.runappdirect:
return target()
space = target.im_self.space
func = app2interp_temp(target.im_func)
w_instance = self.parent.w_instance
self.execute_appex(space, func, space, w_instance)
示例8: runtest
def runtest(self):
target = self.obj
if self.config.option.runappdirect:
return target()
space = target.im_self.space
filename = self._getdynfilename(target)
func = app2interp_temp(target.im_func, filename=filename)
w_instance = self.parent.w_instance
self.execute_appex(space, func, space, w_instance)
示例9: runtest
def runtest(self):
target = self.obj
src = extract_docstring_if_empty_function(target)
if self.config.option.runappdirect:
return run_with_python(self.config.option.python, src, None)
space = gettestobjspace()
filename = self._getdynfilename(target)
func = app2interp_temp(src, filename=filename)
print "executing", func
self.execute_appex(space, func, space)
示例10: test_app2interp_general_args
def test_app2interp_general_args(self):
w = self.space.wrap
def app_general(x, *args, **kwds):
assert type(args) is tuple
assert type(kwds) is dict
return x + 10 * len(args) + 100 * len(kwds)
gg = gateway.app2interp_temp(app_general)
args = gateway.Arguments(self.space, [w(6), w(7)])
assert self.space.int_w(gg(self.space, w(3), args)) == 23
args = gateway.Arguments(self.space, [w(6)], ['hello', 'world'], [w(7), w(8)])
assert self.space.int_w(gg(self.space, w(3), args)) == 213
示例11: test_myexception
def test_myexception(space):
def app_test_func():
x = 6*7
assert x == 43
t = app2interp_temp(app_test_func)
f = t.get_function(space)
space.setitem(space.builtin.w_dict, space.wrap('AssertionError'),
build_pytest_assertion(space))
try:
f.call_args(Arguments(None, []))
except OperationError, e:
assert e.match(space, space.w_AssertionError)
assert space.unwrap(space.str(e.get_w_value(space))) == 'assert 42 == 43'