[pypy-commit] pypy assert-rewrite: Fix rpython/memory/ tests

rlamy pypy.commits at gmail.com
Sun Nov 5 07:33:17 EST 2017


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: assert-rewrite
Changeset: r92945:b7b55dee74c6
Date: 2016-11-29 21:41 +0000
http://bitbucket.org/pypy/pypy/changeset/b7b55dee74c6/

Log:	Fix rpython/memory/ tests

diff --git a/rpython/memory/test/test_hybrid_gc.py b/rpython/memory/test/test_hybrid_gc.py
--- a/rpython/memory/test/test_hybrid_gc.py
+++ b/rpython/memory/test/test_hybrid_gc.py
@@ -2,6 +2,7 @@
 
 from rpython.rtyper.lltypesystem import lltype
 from rpython.rtyper.lltypesystem.lloperation import llop
+from rpython.rlib.objectmodel import assert_
 
 from rpython.memory.test import test_generational_gc
 
@@ -35,12 +36,12 @@
             while i < x:
                 gc.collect()
                 i += 1
-            assert ref() is a
-            assert ref().x == 42
+            assert_(ref() is a)
+            assert_(ref().x == 42)
             return ref
         def step2(ref):
             gc.collect()       # 'a' is freed here
-            assert ref() is None
+            assert_(ref() is None)
         def f(x):
             ref = step1(x)
             step2(ref)
diff --git a/rpython/memory/test/test_incminimark_gc.py b/rpython/memory/test/test_incminimark_gc.py
--- a/rpython/memory/test/test_incminimark_gc.py
+++ b/rpython/memory/test/test_incminimark_gc.py
@@ -2,6 +2,7 @@
 from rpython.rtyper.lltypesystem import lltype
 from rpython.rtyper.lltypesystem.lloperation import llop
 from rpython.rlib import rgc
+from rpython.rlib.objectmodel import assert_
 
 from rpython.memory.test import test_minimark_gc
 
@@ -21,8 +22,8 @@
             a.x = 5
             wr = weakref.ref(a)
             llop.gc__collect(lltype.Void)   # make everything old
-            assert wr() is not None
-            assert a.x == 5
+            assert_(wr() is not None)
+            assert_(a.x == 5)
             return wr
         def f():
             ref = g()
@@ -31,7 +32,7 @@
             # to an object not found, but still reachable:
             b = ref()
             llop.debug_print(lltype.Void, b)
-            assert b is not None
+            assert_(b is not None)
             llop.gc__collect(lltype.Void)   # finish the major cycle
             # assert does not crash, because 'b' is still kept alive
             b.x = 42
@@ -46,7 +47,7 @@
         def f():
             a = A()
             ref = weakref.ref(a)
-            assert not rgc.pin(ref)
+            assert_(not rgc.pin(ref))
         self.interpret(f, [])
 
     def test_pin_finalizer_not_implemented(self):
@@ -63,8 +64,8 @@
         def f():
             a = A()
             b = B()
-            assert not rgc.pin(a)
-            assert not rgc.pin(b)
+            assert_(not rgc.pin(a))
+            assert_(not rgc.pin(b))
         self.interpret(f, [])
 
     def test_weakref_to_pinned(self):
@@ -75,18 +76,18 @@
             pass
         def g():
             a = A()
-            assert rgc.pin(a)
+            assert_(rgc.pin(a))
             a.x = 100
             wr = weakref.ref(a)
             llop.gc__collect(lltype.Void)
-            assert wr() is not None
-            assert a.x == 100
+            assert_(wr() is not None)
+            assert_(a.x == 100)
             return wr
         def f():
             ref = g()
             llop.gc__collect(lltype.Void, 1)
             b = ref()
-            assert b is not None
+            assert_(b is not None)
             b.x = 101
             return ref() is b
         res = self.interpret(f, [])
diff --git a/rpython/memory/test/test_transformed_gc.py b/rpython/memory/test/test_transformed_gc.py
--- a/rpython/memory/test/test_transformed_gc.py
+++ b/rpython/memory/test/test_transformed_gc.py
@@ -15,6 +15,7 @@
 from rpython.rlib.rstring import StringBuilder
 from rpython.rlib.rarithmetic import LONG_BIT
 from rpython.rtyper.rtyper import llinterp_backend
+from rpython.rlib.objectmodel import assert_
 
 
 WORD = LONG_BIT // 8
@@ -804,7 +805,7 @@
                     [A() for i in range(20)]
                 i = 0
                 while i < len(alist):
-                    assert idarray[i] == compute_unique_id(alist[i])
+                    assert_(idarray[i] == compute_unique_id(alist[i]))
                     i += 1
                 j += 1
             lltype.free(idarray, flavor='raw')
@@ -855,7 +856,7 @@
         if cls.gcname == 'incminimark':
             marker = cls.marker
             def cleanup():
-                assert marker[0] > 0
+                assert_(marker[0] > 0)
                 marker[0] = 0
         else:
             cleanup = None
@@ -987,7 +988,7 @@
             for i in range(20):
                 x.append((1, lltype.malloc(S)))
             for i in range(50):
-                assert l2[i] == l[50 + i]
+                assert_(l2[i] == l[50 + i])
             return 0
 
         return fn
@@ -1036,9 +1037,9 @@
             while i < x:
                 all[i] = [i] * i
                 i += 1
-            assert ref() is a
+            assert_(ref() is a)
             llop.gc__collect(lltype.Void)
-            assert ref() is a
+            assert_(ref() is a)
             return a.foo + len(all)
         return f
 
@@ -1115,7 +1116,7 @@
             i = 0
             while i < 17:
                 ref = weakref.ref(a)
-                assert ref() is a
+                assert_(ref() is a)
                 i += 1
             return 0
 
@@ -1182,9 +1183,9 @@
             a1 = A()
             nf1 = nf_a.address[0]
             nt1 = nt_a.address[0]
-            assert nf1 > nf0
-            assert nt1 > nf1
-            assert nt1 == nt0
+            assert_(nf1 > nf0)
+            assert_(nt1 > nf1)
+            assert_(nt1 == nt0)
             return 0
 
         return f
@@ -1359,7 +1360,7 @@
                 hashes.append(compute_identity_hash(obj))
             unique = {}
             for i in range(len(objects)):
-                assert compute_identity_hash(objects[i]) == hashes[i]
+                assert_(compute_identity_hash(objects[i]) == hashes[i])
                 unique[hashes[i]] = None
             return len(unique)
         return fn
diff --git a/rpython/rtyper/test/test_exception.py b/rpython/rtyper/test/test_exception.py
--- a/rpython/rtyper/test/test_exception.py
+++ b/rpython/rtyper/test/test_exception.py
@@ -49,39 +49,39 @@
             try:
                 g(n)
             except IOError as e:
-                assert e.errno == 0
-                assert e.strerror == "test"
-                assert e.filename is None
+                assert_(e.errno == 0)
+                assert_(e.strerror == "test")
+                assert_(e.filename is None)
             else:
-                assert False
+                assert_(False)
             try:
                 h(n)
             except OSError as e:
-                assert e.errno == 42
-                assert e.strerror == "?"
-                assert e.filename is None
+                assert_(e.errno == 42)
+                assert_(e.strerror == "?")
+                assert_(e.filename is None)
             else:
-                assert False
+                assert_(False)
             try:
                 i(n)
             except EnvironmentError as e:
-                assert e.errno == 42
-                assert e.strerror == "?"
-                assert e.filename == "test"
+                assert_(e.errno == 42)
+                assert_(e.strerror == "?")
+                assert_(e.filename == "test")
             else:
-                assert False
+                assert_(False)
             try:
                 j(n)
             except (IOError, OSError) as e:
-                assert e.errno == 0
-                assert e.strerror == "test"
-                assert e.filename is None
+                assert_(e.errno == 0)
+                assert_(e.strerror == "test")
+                assert_(e.filename is None)
             try:
                 k(n)
             except EnvironmentError as e:
-                assert e.errno == 0
-                assert e.strerror is None
-                assert e.filename is None
+                assert_(e.errno == 0)
+                assert_(e.strerror is None)
+                assert_(e.filename is None)
         self.interpret(f, [42])
 
     def test_catch_incompatible_class(self):
@@ -91,7 +91,7 @@
             pass
         def f(n):
             try:
-                assert n < 10
+                assert_(n < 10)
             except MyError as operr:
                 h(operr)
         res = self.interpret(f, [7])


More information about the pypy-commit mailing list