Exemplo n.º 1
0
 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))
Exemplo n.º 2
0
 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'))
Exemplo n.º 3
0
 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 
Exemplo n.º 4
0
 def runtest(self):
     target = self.obj
     if option.runappdirect:
         return target()
     space = gettestobjspace() 
     func = app2interp_temp(target)
     print "executing", func
     self.execute_appex(space, func, space)
Exemplo n.º 5
0
 def execute(self, target, *args):
     assert not args
     if option.runappdirect:
         return target(*args)
     space = gettestobjspace()
     func = app2interp_temp(target)
     print "executing", func
     self.execute_appex(space, func, space)
Exemplo n.º 6
0
    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'))
Exemplo n.º 7
0
 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)
Exemplo n.º 8
0
 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)
Exemplo n.º 9
0
    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'))
Exemplo n.º 10
0
 def runtest(self):
     target = self.obj
     if option.runappdirect:
         return target()
     space = gettestobjspace()
     func = app2interp_temp(target)
     print "executing", func
     self.execute_appex(space, func, space)
Exemplo n.º 11
0
 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) 
Exemplo n.º 12
0
 def execute(self, target, *args):
     assert not args 
     if option.runappdirect:
         return target(*args)
     space = gettestobjspace() 
     func = app2interp_temp(target)
     print "executing", func
     self.execute_appex(space, func, space)
Exemplo n.º 13
0
    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"))
Exemplo n.º 14
0
    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"))
Exemplo n.º 15
0
 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) 
Exemplo n.º 16
0
    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'))
Exemplo n.º 17
0
 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)
Exemplo n.º 18
0
 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)
Exemplo n.º 19
0
 def runtest(self):
     target = self.obj
     if self.config.option.runappdirect:
         return target()
     space = gettestobjspace()
     filename = self._getdynfilename(target)
     func = app2interp_temp(target, filename=filename)
     print "executing", func
     self.execute_appex(space, func, space)
Exemplo n.º 20
0
 def runtest(self):
     target = self.obj
     if self.config.option.runappdirect:
         return target()
     space = gettestobjspace()
     filename = self._getdynfilename(target)
     func = app2interp_temp(target, filename=filename)
     print "executing", func
     self.execute_appex(space, func, space)
Exemplo n.º 21
0
 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)
Exemplo n.º 22
0
 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)
Exemplo n.º 23
0
 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
Exemplo n.º 24
0
 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
Exemplo n.º 25
0
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'
Exemplo n.º 26
0
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'
Exemplo n.º 27
0
 def runtest(self):
     target = self.obj
     src = extract_docstring_if_empty_function(target.im_func)
     space = target.im_self.space
     if self.config.option.runappdirect:
         appexec_definitions = self.parent.obj.__dict__
         spaceconfig = getattr(self.parent.obj, 'spaceconfig', None)
         usemodules = spaceconfig.get('usemodules') if spaceconfig else None
         return run_with_python(self.config.option.python, src, usemodules,
                                **appexec_definitions)
     filename = self._getdynfilename(target)
     func = app2interp_temp(src, filename=filename)
     w_instance = self.parent.w_instance
     self.execute_appex(space, func, space, w_instance)
Exemplo n.º 28
0
 def runtest(self):
     target = self.obj
     src = extract_docstring_if_empty_function(target.im_func)
     space = target.im_self.space
     if self.config.option.runappdirect:
         appexec_definitions = self.parent.obj.__dict__
         spaceconfig = getattr(self.parent.obj, 'spaceconfig', None)
         usemodules = spaceconfig.get('usemodules') if spaceconfig else None
         return run_with_python(self.config.option.python, src, usemodules,
                                **appexec_definitions)
     filename = self._getdynfilename(target)
     func = app2interp_temp(src, filename=filename)
     w_instance = self.parent.w_instance
     self.execute_appex(space, func, space, w_instance)