Пример #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))
Пример #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'))
Пример #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 
Пример #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)
Пример #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)
Пример #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'))
Пример #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)
Пример #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)
Пример #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'))
Пример #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)
Пример #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) 
Пример #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)
Пример #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"))
Пример #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"))
Пример #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) 
Пример #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'))
Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #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
Пример #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
Пример #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'
Пример #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'
Пример #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)
Пример #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)