示例#1
0
def test_applevel_functions(space, applevel_temp = applevel_temp):
    app = applevel_temp('''
        def f(x, y):
            return x-y
        def g(x, y):
            return f(y, x)
    ''')
    g = app.interphook('g')
    w_res = g(space, space.wrap(10), space.wrap(1))
    assert space.eq_w(w_res, space.wrap(-9))
示例#2
0
def test_applevel_functions(space, applevel_temp = applevel_temp):
    app = applevel_temp('''
        def f(x, y):
            return x-y
        def g(x, y):
            return f(y, x)
    ''')
    g = app.interphook('g')
    w_res = g(space, space.wrap(10), space.wrap(1))
    assert space.eq_w(w_res, space.wrap(-9))
示例#3
0
def test_applevel_class(space, applevel_temp = applevel_temp):
    app = applevel_temp('''
        class C(object):
            clsattr = 42
            def __init__(self, x=13):
                self.attr = x
    ''')
    C = app.interphook('C')
    c = C(space, space.wrap(17))
    w_attr = space.getattr(c, space.wrap('clsattr'))
    assert space.eq_w(w_attr, space.wrap(42))
    w_clsattr = space.getattr(c, space.wrap('attr'))
    assert space.eq_w(w_clsattr, space.wrap(17))
示例#4
0
def test_applevel_class(space, applevel_temp = applevel_temp):
    app = applevel_temp('''
        class C(object):
            clsattr = 42 
            def __init__(self, x=13): 
                self.attr = x 
    ''')
    C = app.interphook('C')
    c = C(space, space.wrap(17)) 
    w_attr = space.getattr(c, space.wrap('clsattr'))
    assert space.eq_w(w_attr, space.wrap(42))
    w_clsattr = space.getattr(c, space.wrap('attr'))
    assert space.eq_w(w_clsattr, space.wrap(17))
def test_applevel_class(space, applevel_temp=applevel_temp):
    app = applevel_temp(
        """
        class C(object):
            clsattr = 42 
            def __init__(self, x=13): 
                self.attr = x 
    """
    )
    C = app.interphook("C")
    c = C(space, space.wrap(17))
    w_attr = space.getattr(c, space.wrap("clsattr"))
    assert space.eq_w(w_attr, space.wrap(42))
    w_clsattr = space.getattr(c, space.wrap("attr"))
    assert space.eq_w(w_clsattr, space.wrap(17))