Author: Greg Price <pr...@mit.edu>
Branch: signatures
Changeset: r59311:65c137eb5b0d
Date: 2012-12-02 16:41 -0800
http://bitbucket.org/pypy/pypy/changeset/65c137eb5b0d/

Log:    refactor signature tests

diff --git a/pypy/rlib/test/test_objectmodel.py 
b/pypy/rlib/test/test_objectmodel.py
--- a/pypy/rlib/test/test_objectmodel.py
+++ b/pypy/rlib/test/test_objectmodel.py
@@ -498,18 +498,20 @@
     assert f.foo == 'foo'
     assert f(1, 'hello') == 6
 
+def annotate_at(f):
+    t = TranslationContext()
+    a = t.buildannotator()
+    a.annotate_helper(f, [model.s_ImpossibleValue]*f.func_code.co_argcount)
+    return a, t
+
 def getsig(f):
     # returns [param1, param2, ..., ret]
-    t = TranslationContext()
-    a = t.buildannotator()
-    g = a.annotate_helper(f, [model.s_ImpossibleValue]*f.func_code.co_argcount)
+    a, t = annotate_at(f)
+    g = graphof(t, f)
     return [a.bindings[v] for v in g.startblock.inputargs] + 
[a.bindings[g.getreturnvar()]]
 
 def check_annotator_fails(caller):
-    t = TranslationContext()
-    a = t.buildannotator()
-    exc = py.test.raises(Exception, a.annotate_helper, caller,
-                         
[model.s_ImpossibleValue]*caller.func_code.co_argcount).value
+    exc = py.test.raises(Exception, annotate_at, caller).value
     assert caller.func_name in repr(exc.args)
 
 def test_signature_basic():
@@ -540,9 +542,7 @@
         return x
     def g():
         return f('a')
-    t = TranslationContext()
-    a = t.buildannotator()
-    a.annotate_helper(g, [])
+    a, t = annotate_at(g)
     assert a.bindings[graphof(t, f).startblock.inputargs[0]] == 
model.SomeString()
     assert a.bindings[graphof(t, f).getreturnvar()] == model.SomeString()
 
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to