[pypy-commit] pypy fix-broken-types: fix more tests

rlamy pypy.commits at gmail.com
Wed Nov 23 00:04:19 EST 2016


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: fix-broken-types
Changeset: r88566:186e0cdffeb1
Date: 2016-11-23 04:29 +0000
http://bitbucket.org/pypy/pypy/changeset/186e0cdffeb1/

Log:	fix more tests

diff --git a/rpython/rlib/test/test_objectmodel.py b/rpython/rlib/test/test_objectmodel.py
--- a/rpython/rlib/test/test_objectmodel.py
+++ b/rpython/rlib/test/test_objectmodel.py
@@ -502,13 +502,6 @@
         return a + b
     assert f._annenforceargs_ == (None, int, None)
 
-def test_enforceargs_int_float_promotion():
-    @enforceargs(float)
-    def f(x):
-        return x
-    # in RPython there is an implicit int->float promotion
-    assert f(42) == 42
-
 def test_enforceargs_None_string():
     @enforceargs(str, unicode)
     def f(a, b):
@@ -540,7 +533,7 @@
     @enforceargs(int, float)
     def f(a, b):
         return a, b
-    graph = getgraph(f, [int, int])
+    graph = getgraph(f, [int, float])
     TYPES = [v.concretetype for v in graph.getargs()]
     assert TYPES == [lltype.Signed, lltype.Float]
 
@@ -623,7 +616,7 @@
 def test_iterkeys_with_hash():
     def f(i):
         d = {i + .0: 5, i + .5: 6}
-        total = 0
+        total = 0.
         for k, h in iterkeys_with_hash(d):
             total += k * h
         total -= (i + 0.0) * compute_hash(i + 0.0)
@@ -637,7 +630,7 @@
 def test_iteritems_with_hash():
     def f(i):
         d = {i + .0: 5, i + .5: 6}
-        total = 0
+        total = 0.
         for k, v, h in iteritems_with_hash(d):
             total += k * h * v
         total -= (i + 0.0) * compute_hash(i + 0.0) * 5
diff --git a/rpython/rlib/test/test_signature.py b/rpython/rlib/test/test_signature.py
--- a/rpython/rlib/test/test_signature.py
+++ b/rpython/rlib/test/test_signature.py
@@ -257,7 +257,7 @@
         return x + y
     @signature(types.int(), returns=types.float())
     def g(x):
-        return f(x, x)
+        return f(x + 0.5, x)
     sig = getsig(g)
     assert sig == [model.SomeInteger(), model.SomeFloat()]
 
@@ -267,11 +267,12 @@
     sig = getsig(g)
     assert sig == [model.SomeFloat(), model.SomeFloat()]
 
-    @signature(types.str(), returns=types.int())
+    @signature(types.str(), returns=types.float())
     def cannot_add_string(x):
         return f(x, 2)
-    exc = py.test.raises(model.AnnotatorError, annotate_at, cannot_add_string).value
-    assert 'Blocked block' in str(exc)
+    with py.test.raises(model.AnnotatorError) as excinfo:
+        annotate_at(cannot_add_string)
+    assert 'Blocked block' in str(excinfo.value)
 
 def test_return_any():
     @signature(types.int(), returns=types.any())
diff --git a/rpython/rtyper/lltypesystem/test/test_lltype.py b/rpython/rtyper/lltypesystem/test/test_lltype.py
--- a/rpython/rtyper/lltypesystem/test/test_lltype.py
+++ b/rpython/rtyper/lltypesystem/test/test_lltype.py
@@ -549,7 +549,7 @@
     1, sys.maxint, 1.5, 'a', 'abc', u'abc', None, [],
     lambda: None,
     {1.23: 'abc'},
-    (1, 'x', [2, 3.],),
+    (1, 'x', [2, 3],),
     Frozen(),])
 def test_typeOf_const(x):
     a = RPythonAnnotator()


More information about the pypy-commit mailing list