Author: Alex Gaynor <[email protected]>
Branch: kill-someobject
Changeset: r57887:7e43c5977f39
Date: 2012-10-08 11:52 +0200
http://bitbucket.org/pypy/pypy/changeset/7e43c5977f39/
Log: Remove some import * from tests
diff --git a/pypy/rpython/lltypesystem/lltype.py
b/pypy/rpython/lltypesystem/lltype.py
--- a/pypy/rpython/lltypesystem/lltype.py
+++ b/pypy/rpython/lltypesystem/lltype.py
@@ -1,9 +1,7 @@
-import py
from pypy.rlib.rarithmetic import (r_int, r_uint, intmask, r_singlefloat,
r_ulonglong, r_longlong, r_longfloat,
r_longlonglong,
base_int, normalizedinttype, longlongmask,
longlonglongmask)
from pypy.rlib.objectmodel import Symbolic
-from pypy.tool.uid import Hashable
from pypy.tool.identity_dict import identity_dict
from pypy.tool import leakfinder
from types import NoneType
diff --git a/pypy/rpython/test/test_rlist.py b/pypy/rpython/test/test_rlist.py
--- a/pypy/rpython/test/test_rlist.py
+++ b/pypy/rpython/test/test_rlist.py
@@ -1,31 +1,32 @@
import sys
import re
+
import py
-from pypy.translator.translator import TranslationContext
+
+from pypy.rlib.debug import ll_assert
from pypy.rpython.error import TyperError
-from pypy.rpython.lltypesystem.lltype import *
-from pypy.rpython.ootypesystem import ootype
-from pypy.rpython.rlist import *
+from pypy.rpython.llinterp import LLException
+from pypy.rpython.lltypesystem import rlist as ll_rlist
from pypy.rpython.lltypesystem.rlist import ListRepr, FixedSizeListRepr,
ll_newlist, ll_fixed_newlist
-from pypy.rpython.lltypesystem import rlist as ll_rlist
-from pypy.rpython.llinterp import LLException
from pypy.rpython.ootypesystem import rlist as oo_rlist
from pypy.rpython.rint import signed_repr
-from pypy.objspace.flow.model import Constant, Variable
+from pypy.rpython.rlist import *
from pypy.rpython.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
-from pypy.rlib.debug import ll_assert
+from pypy.translator.translator import TranslationContext
+
# undo the specialization parameter
for n1 in 'get set del'.split():
- for n2 in '','_nonneg':
+ for n2 in '', '_nonneg':
name = 'll_%sitem%s' % (n1, n2)
- globals()['_'+name] = globals()[name]
+ globals()['_' + name] = globals()[name]
exec """if 1:
def %s(*args):
return _%s(dum_checkidx, *args)
""" % (name, name)
del n1, n2, name
+
class BaseTestListImpl:
def check_list(self, l1, expected):
@@ -88,8 +89,6 @@
class TestListImpl(BaseTestListImpl):
-
-
def sample_list(self): # [42, 43, 44, 45]
rlist = ListRepr(None, signed_repr)
rlist.setup()
@@ -134,8 +133,8 @@
del expected[start:stop]
self.check_list(l, expected)
+
class TestFixedSizeListImpl(BaseTestListImpl):
-
def sample_list(self): # [42, 43, 44, 45]
rlist = FixedSizeListRepr(None, signed_repr)
rlist.setup()
@@ -207,7 +206,7 @@
l.append(90)
return len(l), l[0], l[-1]
res = self.interpret(dummyfn, [])
- assert res.item0 == 5
+ assert res.item0 == 5
assert res.item1 == 50
assert res.item2 == 90
@@ -271,7 +270,6 @@
res = self.interpret(dummyfn, [])
assert res == 25
-
def test_recursive(self):
def dummyfn(N):
l = []
@@ -294,14 +292,14 @@
def test_add(self):
def dummyfn():
l = [5]
- l += [6,7]
+ l += [6, 7]
return l + [8]
res = self.interpret(dummyfn, [])
assert self.ll_to_list(res) == [5, 6, 7, 8]
def dummyfn():
l = [5]
- l += [6,7]
+ l += [6, 7]
l2 = l + [8]
l2.append(9)
return l2
@@ -369,7 +367,7 @@
return len(l)
res = self.interpret(dummyfn, [])
assert res == 0
-
+
def test_setslice(self):
def dummyfn():
l = [10, 9, 8, 7]
@@ -417,9 +415,11 @@
for resize2 in [False, True]:
def dummyfn():
l1 = [42]
- if resize1: l1.append(43)
+ if resize1:
+ l1.append(43)
l2 = list(l1)
- if resize2: l2.append(44)
+ if resize2:
+ l2.append(44)
l2[0] = 0
return l1[0]
res = self.interpret(dummyfn, ())
@@ -443,9 +443,9 @@
def test_list_index_simple(self):
def dummyfn(i):
- l = [5,6,7,8]
+ l = [5, 6, 7, 8]
return l.index(i)
-
+
res = self.interpret(dummyfn, (6,))
assert res == 1
self.interpret_raises(ValueError, dummyfn, [42])
@@ -460,7 +460,7 @@
l.pop(-1)
l.pop()
return l[-1]
- res = self.interpret(dummyfn, ())#, view=True)
+ res = self.interpret(dummyfn, ())
assert res == 42
def test_insert_bug(self):
@@ -492,7 +492,7 @@
res = self.interpret(f, [1])
assert self.class_name(res) == 'A'
#''.join(res.super.typeptr.name) == 'A\00'
-
+
def test_reverse(self):
def dummyfn():
l = [5, 3, 2]
@@ -881,7 +881,7 @@
i += 1
return str(l)
res = self.ll_to_string(self.interpret(fn, []))
- res = res.replace('pypy.rpython.test.test_rlist.', '')
+ res = res.replace('pypy.rpython.test.test_rlist.', '')
res = re.sub(' at 0x[a-z0-9]+', '', res)
assert res == '[<Foo object>, <Bar object>, <Bar object>, <Foo
object>, <Foo object>]'
@@ -990,12 +990,12 @@
del l[1]
l.append(i)
listlen = len(l)
- l.extend(l)
+ l.extend(l)
del l[listlen:]
- l += [5,6]
+ l += [5,6]
l[1] = i
return l[j]
- for i in range(6):
+ for i in range(6):
for j in range(6):
res = self.interpret(list_basic_ops, [i, j])
assert res == list_basic_ops(i, j)
@@ -1138,7 +1138,7 @@
res = self.interpret(f, [0])
assert res == 1
res = self.interpret(f, [1])
- assert res == -1
+ assert res == -1
def f(x):
l = [1]
@@ -1161,7 +1161,7 @@
res = self.interpret(f, [0])
assert res == 1
-
+
def test_getitem_exc_2(self):
def f(x):
l = [1]
@@ -1189,7 +1189,7 @@
res = self.interpret(f, [0])
assert res == 1
res = self.interpret(f, [1])
- assert res == -1
+ assert res == -1
def f(x):
l = [1]
@@ -1449,7 +1449,7 @@
r_A_list = rtyper.getrepr(s_A_list)
assert isinstance(r_A_list, self.rlist.FixedSizeListRepr)
r_B_list = rtyper.getrepr(s_B_list)
- assert isinstance(r_B_list, self.rlist.FixedSizeListRepr)
+ assert isinstance(r_B_list, self.rlist.FixedSizeListRepr)
assert r_A_list.lowleveltype == r_B_list.lowleveltype
diff --git a/pypy/rpython/test/test_rpbc.py b/pypy/rpython/test/test_rpbc.py
--- a/pypy/rpython/test/test_rpbc.py
+++ b/pypy/rpython/test/test_rpbc.py
@@ -1,9 +1,9 @@
import py
-from pypy.rpython.lltypesystem.lltype import *
-from pypy.rpython.rtyper import RPythonTyper
-from pypy.rpython.ootypesystem import ootype
+
+from pypy.annotation import policy, specialize
+from pypy.rpython.lltypesystem.lltype import typeOf
from pypy.rpython.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
-from pypy.annotation import policy, specialize
+
class MyBase:
def m(self, x):
diff --git a/pypy/rpython/test/test_rptr.py b/pypy/rpython/test/test_rptr.py
--- a/pypy/rpython/test/test_rptr.py
+++ b/pypy/rpython/test/test_rptr.py
@@ -1,11 +1,13 @@
-import py, sys
+import sys
+
+import py
+
+from pypy.annotation import model as annmodel
from pypy.annotation.annrpython import RPythonAnnotator
+from pypy.rlib.rarithmetic import is_valid_int
from pypy.rpython.annlowlevel import annotate_lowlevel_helper,
LowLevelAnnotatorPolicy
-from pypy.rpython.lltypesystem.lltype import *
-from pypy.rpython.lltypesystem import llmemory
+from pypy.rpython.lltypesystem import llmemory, lltype
from pypy.rpython.rtyper import RPythonTyper
-from pypy.annotation import model as annmodel
-from pypy.rlib.rarithmetic import is_valid_int
# ____________________________________________________________
@@ -22,29 +24,29 @@
return s, t
def test_cast_pointer():
- S = GcStruct('s', ('x', Signed))
- S1 = GcStruct('s1', ('sub', S))
- S2 = GcStruct('s2', ('sub', S1))
- PS = Ptr(S)
- PS2 = Ptr(S2)
+ S = lltype.GcStruct('s', ('x', lltype.Signed))
+ S1 = lltype.GcStruct('s1', ('sub', S))
+ S2 = lltype.GcStruct('s2', ('sub', S1))
+ PS = lltype.Ptr(S)
+ PS2 = lltype.Ptr(S2)
def lldown(p):
- return cast_pointer(PS, p)
+ return lltype.cast_pointer(PS, p)
s, t = ll_rtype(lldown, [annmodel.SomePtr(PS2)])
assert s.ll_ptrtype == PS
def llup(p):
- return cast_pointer(PS2, p)
+ return lltype.cast_pointer(PS2, p)
s, t = ll_rtype(llup, [annmodel.SomePtr(PS)])
assert s.ll_ptrtype == PS2
def test_runtime_type_info():
- S = GcStruct('s', ('x', Signed), rtti=True)
+ S = lltype.GcStruct('s', ('x', lltype.Signed), rtti=True)
def ll_example(p):
- return (runtime_type_info(p),
- runtime_type_info(p) == getRuntimeTypeInfo(S))
+ return (lltype.runtime_type_info(p),
+ lltype.runtime_type_info(p) == lltype.getRuntimeTypeInfo(S))
- assert ll_example(malloc(S)) == (getRuntimeTypeInfo(S), True)
- s, t = ll_rtype(ll_example, [annmodel.SomePtr(Ptr(S))])
- assert s == annmodel.SomeTuple([annmodel.SomePtr(Ptr(RuntimeTypeInfo)),
+ assert ll_example(lltype.malloc(S)) == (lltype.getRuntimeTypeInfo(S), True)
+ s, t = ll_rtype(ll_example, [annmodel.SomePtr(lltype.Ptr(S))])
+ assert s ==
annmodel.SomeTuple([annmodel.SomePtr(lltype.Ptr(lltype.RuntimeTypeInfo)),
annmodel.SomeBool()])
from pypy.rpython.test.test_llinterp import interpret, gengraph
@@ -53,9 +55,9 @@
policy = LowLevelAnnotatorPolicy()
def h_newstruct():
- return malloc(S)
-
- S = GcStruct('s', ('x', Signed),
+ return lltype.malloc(S)
+
+ S = lltype.GcStruct('s', ('x', lltype.Signed),
adtmeths={"h_newstruct": h_newstruct})
def f():
@@ -63,14 +65,14 @@
s = interpret(f, [], policy=policy)
- assert typeOf(s) == Ptr(S)
+ assert lltype.typeOf(s) == lltype.Ptr(S)
def h_alloc(n):
- return malloc(A, n)
+ return lltype.malloc(A, n)
def h_length(a):
return len(a)
- A = GcArray(Signed,
+ A = lltype.GcArray(lltype.Signed,
adtmeths={"h_alloc": h_alloc,
"h_length": h_length,
'flag': True})
@@ -80,9 +82,9 @@
a = interpret(f, [], policy=policy)
- assert typeOf(a) == Ptr(A)
+ assert lltype.typeOf(a) == lltype.Ptr(A)
assert len(a) == 10
-
+
def f():
a = A.h_alloc(10)
@@ -97,72 +99,72 @@
assert res
def test_odd_ints():
- T = GcStruct('T')
- S = GcStruct('S', ('t', T))
- PT = Ptr(T)
- PS = Ptr(S)
+ T = lltype.GcStruct('T')
+ S = lltype.GcStruct('S', ('t', T))
+ PT = lltype.Ptr(T)
+ PS = lltype.Ptr(S)
def fn(n):
- s = cast_int_to_ptr(PS, n)
- assert typeOf(s) == PS
- assert cast_ptr_to_int(s) == n
- t = cast_pointer(PT, s)
- assert typeOf(t) == PT
- assert cast_ptr_to_int(t) == n
- assert s == cast_pointer(PS, t)
+ s = lltype.cast_int_to_ptr(PS, n)
+ assert lltype.typeOf(s) == PS
+ assert lltype.cast_ptr_to_int(s) == n
+ t = lltype.cast_pointer(PT, s)
+ assert lltype.typeOf(t) == PT
+ assert lltype.cast_ptr_to_int(t) == n
+ assert s == lltype.cast_pointer(PS, t)
interpret(fn, [11521])
def test_odd_ints_opaque():
- T = GcStruct('T')
- Q = GcOpaqueType('Q')
- PT = Ptr(T)
- PQ = Ptr(Q)
+ T = lltype.GcStruct('T')
+ Q = lltype.GcOpaqueType('Q')
+ PT = lltype.Ptr(T)
+ PQ = lltype.Ptr(Q)
def fn(n):
- t = cast_int_to_ptr(PT, n)
- assert typeOf(t) == PT
- assert cast_ptr_to_int(t) == n
- o = cast_opaque_ptr(PQ, t)
- assert cast_ptr_to_int(o) == n
+ t = lltype.cast_int_to_ptr(PT, n)
+ assert lltype.typeOf(t) == PT
+ assert lltype.cast_ptr_to_int(t) == n
+ o = lltype.cast_opaque_ptr(PQ, t)
+ assert lltype.cast_ptr_to_int(o) == n
fn(13)
interpret(fn, [11521])
-def test_Ptr():
- S = GcStruct('s')
+def test_ptr():
+ S = lltype.GcStruct('s')
def ll_example():
- return malloc(Ptr(S).TO)
-
+ return lltype.malloc(lltype.Ptr(S).TO)
+
p = interpret(ll_example, [])
- assert typeOf(p) == Ptr(S)
+ assert lltype.typeOf(p) == lltype.Ptr(S)
def test_cast_opaque_ptr():
- O = GcOpaqueType('O')
- Q = GcOpaqueType('Q')
- S = GcStruct('S', ('x', Signed))
+ O = lltype.GcOpaqueType('O')
+ Q = lltype.GcOpaqueType('Q')
+ S = lltype.GcStruct('S', ('x', lltype.Signed))
def fn():
- s = malloc(S)
- o = cast_opaque_ptr(Ptr(O), s)
- q = cast_opaque_ptr(Ptr(Q), o)
- p = cast_opaque_ptr(Ptr(S), q)
+ s = lltype.malloc(S)
+ o = lltype.cast_opaque_ptr(lltype.Ptr(O), s)
+ q = lltype.cast_opaque_ptr(lltype.Ptr(Q), o)
+ p = lltype.cast_opaque_ptr(lltype.Ptr(S), q)
return p == s
res = interpret(fn, [])
assert res is True
- O1 = OpaqueType('O')
- S1 = Struct('S1', ('x', Signed))
- s1 = malloc(S1, immortal=True)
+ O1 = lltype.OpaqueType('O')
+ S1 = lltype.Struct('S1', ('x', lltype.Signed))
+ s1 = lltype.malloc(S1, immortal=True)
def fn1():
- o1 = cast_opaque_ptr(Ptr(O1), s1)
- p1 = cast_opaque_ptr(Ptr(S1), o1)
+ o1 = lltype.cast_opaque_ptr(lltype.Ptr(O1), s1)
+ p1 = lltype.cast_opaque_ptr(lltype.Ptr(S1), o1)
return p1 == s1
res = interpret(fn1, [])
assert res is True
def test_address():
- S = GcStruct('S')
- p1 = nullptr(S)
- p2 = malloc(S)
-
+ S = lltype.GcStruct('S')
+ p1 = lltype.nullptr(S)
+ p2 = lltype.malloc(S)
+
def g(p):
return bool(llmemory.cast_ptr_to_adr(p))
def fn(n):
@@ -177,8 +179,8 @@
assert res is True
def test_cast_adr_to_int():
- S = Struct('S')
- p = malloc(S, immortal=True)
+ S = lltype.Struct('S')
+ p = lltype.malloc(S, immortal=True)
def fn(n):
a = llmemory.cast_ptr_to_adr(p)
if n == 2:
@@ -190,7 +192,7 @@
res = interpret(fn, [2])
assert is_valid_int(res)
- assert res == cast_ptr_to_int(p)
+ assert res == lltype.cast_ptr_to_int(p)
#
res = interpret(fn, [4])
assert isinstance(res, llmemory.AddressAsInt)
@@ -199,60 +201,60 @@
res = interpret(fn, [6])
assert is_valid_int(res)
from pypy.rpython.lltypesystem import rffi
- assert res == rffi.cast(Signed, p)
+ assert res == rffi.cast(lltype.Signed, p)
def test_flavored_malloc():
- T = GcStruct('T', ('y', Signed))
+ T = lltype.GcStruct('T', ('y', lltype.Signed))
def fn(n):
- p = malloc(T, flavor='gc')
+ p = lltype.malloc(T, flavor='gc')
p.y = n
return p.y
res = interpret(fn, [232])
assert res == 232
- S = Struct('S', ('x', Signed))
+ S = lltype.Struct('S', ('x', lltype.Signed))
def fn(n):
- p = malloc(S, flavor='raw')
+ p = lltype.malloc(S, flavor='raw')
p.x = n
result = p.x
- free(p, flavor='raw')
- return n
+ lltype.free(p, flavor='raw')
+ return result
res = interpret(fn, [23])
assert res == 23
- S = Struct('S', ('x', Signed))
+ S = lltype.Struct('S', ('x', lltype.Signed))
def fn(n):
- p = malloc(S, flavor='raw', track_allocation=False)
+ p = lltype.malloc(S, flavor='raw', track_allocation=False)
p.x = n
result = p.x
- return n
+ return result
res = interpret(fn, [23])
assert res == 23
- S = Struct('S', ('x', Signed))
+ S = lltype.Struct('S', ('x', lltype.Signed))
def fn(n):
- p = malloc(S, flavor='raw', track_allocation=False)
+ p = lltype.malloc(S, flavor='raw', track_allocation=False)
p.x = n
result = p.x
- free(p, flavor='raw', track_allocation=False)
- return n
+ lltype.free(p, flavor='raw', track_allocation=False)
+ return result
res = interpret(fn, [23])
assert res == 23
def test_memoryerror():
- A = Array(Signed)
+ A = lltype.Array(lltype.Signed)
def fn(n):
try:
- a = malloc(A, n, flavor='raw')
+ a = lltype.malloc(A, n, flavor='raw')
except MemoryError:
return -42
else:
res = len(a)
- free(a, flavor='raw')
+ lltype.free(a, flavor='raw')
return res
res = interpret(fn, [123])
@@ -263,23 +265,23 @@
def test_call_ptr():
- def f(x,y,z):
+ def f(x, y, z):
return x+y+z
- FTYPE = FuncType([Signed, Signed, Signed], Signed)
- fptr = functionptr(FTYPE, "f", _callable=f)
+ FTYPE = lltype.FuncType([lltype.Signed, lltype.Signed, lltype.Signed],
lltype.Signed)
+ fptr = lltype.functionptr(FTYPE, "f", _callable=f)
- def g(x,y,z):
+ def g(x, y, z):
tot = 0
- tot += fptr(x,y,z)
- tot += fptr(*(x,y,z))
- tot += fptr(x, *(x,z))
+ tot += fptr(x, y, z)
+ tot += fptr(*(x, y, z))
+ tot += fptr(x, *(x, z))
return tot
- res = interpret(g, [1,2,4])
- assert res == g(1,2,4)
+ res = interpret(g, [1, 2, 4])
+ assert res == g(1, 2, 4)
- def wrong(x,y):
- fptr(*(x,y))
+ def wrong(x, y):
+ fptr(*(x, y))
py.test.raises(TypeError, "interpret(wrong, [1, 2])")
@@ -288,8 +290,8 @@
def f():
return str(p)
- S = GcStruct('S', ('x', Signed))
- p = malloc(S)
+ S = lltype.GcStruct('S', ('x', lltype.Signed))
+ p = lltype.malloc(S)
res = interpret(f, [])
assert res.chars[0] == '0'
@@ -297,10 +299,10 @@
def test_first_subfield_access_is_cast_pointer():
- B = GcStruct("B", ('x', Signed))
- C = GcStruct("C", ('super', B), ('y', Signed))
+ B = lltype.GcStruct("B", ('x', lltype.Signed))
+ C = lltype.GcStruct("C", ('super', B), ('y', lltype.Signed))
def f():
- c = malloc(C)
+ c = lltype.malloc(C)
c.super.x = 1
c.y = 2
return c.super.x + c.y
@@ -311,73 +313,73 @@
graphsum = summary(graph)
assert 'getsubstruct' not in graphsum
assert 'cast_pointer' in graphsum
-
-
+
+
def test_interior_ptr():
- S = Struct("S", ('x', Signed))
- T = GcStruct("T", ('s', S))
+ S = lltype.Struct("S", ('x', lltype.Signed))
+ T = lltype.GcStruct("T", ('s', S))
def f():
- t = malloc(T)
+ t = lltype.malloc(T)
t.s.x = 1
return t.s.x
res = interpret(f, [])
assert res == 1
def test_interior_ptr_with_index():
- S = Struct("S", ('x', Signed))
- T = GcArray(S)
+ S = lltype.Struct("S", ('x', lltype.Signed))
+ T = lltype.GcArray(S)
def f():
- t = malloc(T, 1)
+ t = lltype.malloc(T, 1)
t[0].x = 1
return t[0].x
res = interpret(f, [])
assert res == 1
def test_interior_ptr_with_field_and_index():
- S = Struct("S", ('x', Signed))
- T = GcStruct("T", ('items', Array(S)))
+ S = lltype.Struct("S", ('x', lltype.Signed))
+ T = lltype.GcStruct("T", ('items', lltype.Array(S)))
def f():
- t = malloc(T, 1)
+ t = lltype.malloc(T, 1)
t.items[0].x = 1
return t.items[0].x
res = interpret(f, [])
assert res == 1
def test_interior_ptr_with_index_and_field():
- S = Struct("S", ('x', Signed))
- T = Struct("T", ('s', S))
- U = GcArray(T)
+ S = lltype.Struct("S", ('x', lltype.Signed))
+ T = lltype.Struct("T", ('s', S))
+ U = lltype.GcArray(T)
def f():
- u = malloc(U, 1)
+ u = lltype.malloc(U, 1)
u[0].s.x = 1
return u[0].s.x
res = interpret(f, [])
assert res == 1
def test_interior_ptr_len():
- S = Struct("S", ('x', Signed))
- T = GcStruct("T", ('items', Array(S)))
+ S = lltype.Struct("S", ('x', lltype.Signed))
+ T = lltype.GcStruct("T", ('items', lltype.Array(S)))
def f():
- t = malloc(T, 1)
+ t = lltype.malloc(T, 1)
return len(t.items)
res = interpret(f, [])
assert res == 1
def test_interior_ptr_with_setitem():
- T = GcStruct("T", ('s', Array(Signed)))
+ T = lltype.GcStruct("T", ('s', lltype.Array(lltype.Signed)))
def f():
- t = malloc(T, 1)
+ t = lltype.malloc(T, 1)
t.s[0] = 1
return t.s[0]
res = interpret(f, [])
assert res == 1
-
-def test_isinstance_Ptr():
- S = GcStruct("S", ('x', Signed))
+
+def test_isinstance_ptr():
+ S = lltype.GcStruct("S", ('x', lltype.Signed))
def f(n):
- x = isinstance(Signed, Ptr)
- return x + (typeOf(x) is Ptr(S)) + len(n)
+ x = isinstance(lltype.Signed, lltype.Ptr)
+ return x + (lltype.typeOf(x) is lltype.Ptr(S)) + len(n)
def lltest():
f([])
return f([1])
@@ -385,10 +387,10 @@
assert s.is_constant() == False
def test_staticadtmeths():
- ll_func = staticAdtMethod(lambda x: x + 42)
- S = GcStruct('S', adtmeths={'ll_func': ll_func})
+ ll_func = lltype.staticAdtMethod(lambda x: x + 42)
+ S = lltype.GcStruct('S', adtmeths={'ll_func': ll_func})
def f():
- return malloc(S).ll_func(5)
+ return lltype.malloc(S).ll_func(5)
s, t = ll_rtype(f, [])
graphf = t.graphs[0]
for op in graphf.startblock.operations:
diff --git a/pypy/rpython/test/test_rrange.py b/pypy/rpython/test/test_rrange.py
--- a/pypy/rpython/test/test_rrange.py
+++ b/pypy/rpython/test/test_rrange.py
@@ -1,6 +1,6 @@
-from pypy.rpython.rrange import *
+from pypy.rlib.rarithmetic import intmask
+from pypy.rpython.rrange import ll_rangelen, ll_rangeitem,
ll_rangeitem_nonneg, dum_nocheck
from pypy.rpython.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
-from pypy.rlib.rarithmetic import intmask
class BaseTestRrange(BaseRtypingTest):
@@ -14,7 +14,7 @@
step = l.step
else:
RANGE = self.rrange.RangeRepr(step).RANGE
- l = self.rrange.ll_newrange(RANGE,start,stop)
+ l = self.rrange.ll_newrange(RANGE, start, stop)
assert ll_rangelen(l, step) == length
lst = [ll_rangeitem(dum_nocheck, l, i, step) for i in
range(length)]
assert lst == expected
diff --git a/pypy/rpython/test/test_rstr.py b/pypy/rpython/test/test_rstr.py
--- a/pypy/rpython/test/test_rstr.py
+++ b/pypy/rpython/test/test_rstr.py
@@ -1,12 +1,14 @@
import random
-from pypy.rpython.lltypesystem.lltype import *
+
+import py
+
+from pypy.objspace.flow.model import summary
+from pypy.rpython.lltypesystem.lltype import typeOf, Signed, malloc
+from pypy.rpython.lltypesystem.rstr import LLHelpers, STR
from pypy.rpython.rstr import AbstractLLHelpers
-from pypy.rpython.lltypesystem.rstr import LLHelpers, STR
-from pypy.rpython.ootypesystem.ootype import make_string
-from pypy.rpython.rtyper import RPythonTyper, TyperError
+from pypy.rpython.rtyper import TyperError
from pypy.rpython.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
-from pypy.rpython.llinterp import LLException
-from pypy.objspace.flow.model import summary
+
def test_parse_fmt():
parse = AbstractLLHelpers.parse_fmt_string
@@ -14,6 +16,7 @@
assert parse('%s') == [('s',)]
assert parse("name '%s' is not defined") == ["name '", ("s",), "' is not
defined"]
+
class AbstractTestRstr(BaseRtypingTest):
def test_simple(self):
const = self.const
diff --git a/pypy/rpython/test/test_rtuple.py b/pypy/rpython/test/test_rtuple.py
--- a/pypy/rpython/test/test_rtuple.py
+++ b/pypy/rpython/test/test_rtuple.py
@@ -1,11 +1,10 @@
+from pypy.rpython.lltypesystem import rtupletype
+from pypy.rpython.lltypesystem.lltype import Signed, Bool
+from pypy.rpython.rbool import bool_repr
+from pypy.rpython.rint import signed_repr
+from pypy.rpython.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
from pypy.translator.translator import TranslationContext
-from pypy.rpython.lltypesystem.lltype import *
-from pypy.rpython.lltypesystem import rtupletype
-from pypy.rpython.ootypesystem import ootype
-from pypy.rpython.rint import signed_repr
-from pypy.rpython.rbool import bool_repr
-from pypy.rpython.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
-import py
+
def test_rtuple():
from pypy.rpython.lltypesystem.rtuple import TupleRepr
@@ -18,9 +17,9 @@
def test_simple(self):
def dummyfn(x):
- l = (10,x,30)
+ l = (10, x, 30)
return l[2]
- res = self.interpret(dummyfn,[4])
+ res = self.interpret(dummyfn, [4])
assert res == 30
def test_len(self):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit