[pypy-svn] r51583 - pypy/dist/pypy/lib/app_test/ctypes

fijal at codespeak.net fijal at codespeak.net
Mon Feb 18 15:54:43 CET 2008


Author: fijal
Date: Mon Feb 18 15:54:42 2008
New Revision: 51583

Modified:
   pypy/dist/pypy/lib/app_test/ctypes/support.py
   pypy/dist/pypy/lib/app_test/ctypes/test_array.py
   pypy/dist/pypy/lib/app_test/ctypes/test_keepalive.py
   pypy/dist/pypy/lib/app_test/ctypes/test_unions.py
Log:
More strict checks


Modified: pypy/dist/pypy/lib/app_test/ctypes/support.py
==============================================================================
--- pypy/dist/pypy/lib/app_test/ctypes/support.py	(original)
+++ pypy/dist/pypy/lib/app_test/ctypes/support.py	Mon Feb 18 15:54:42 2008
@@ -6,6 +6,8 @@
         except ImportError:
             pass
         else:
+            import gc
+            gc.collect()
             cls.old_num = _rawffi._num_of_allocated_objects()
     
     def teardown_class(cls):
@@ -17,5 +19,7 @@
         else:
             import gc
             gc.collect()
+            gc.collect()
+            gc.collect()
             # there is one reference coming from the byref() above
-            assert _rawffi._num_of_allocated_objects() <= cls.old_num
+            assert _rawffi._num_of_allocated_objects() == cls.old_num

Modified: pypy/dist/pypy/lib/app_test/ctypes/test_array.py
==============================================================================
--- pypy/dist/pypy/lib/app_test/ctypes/test_array.py	(original)
+++ pypy/dist/pypy/lib/app_test/ctypes/test_array.py	Mon Feb 18 15:54:42 2008
@@ -1,13 +1,15 @@
 
 import py
 from ctypes import *
+from support import BaseCTypesTestChecker
+import _rawffi
 
 formats = "bBhHiIlLqQfd"
 
 formats = c_byte, c_ubyte, c_short, c_ushort, c_int, c_uint, \
           c_long, c_ulonglong, c_float, c_double
 
-class TestArray:
+class TestArray(BaseCTypesTestChecker):
     def test_simple(self):
         # create classes holding simple numeric types, and check
         # various properties.
@@ -109,8 +111,14 @@
             assert sz[:] == "foo"
             assert sz.value == "foo"
 
-class TestSophisticatedThings:
+class TestSophisticatedThings(BaseCTypesTestChecker):
     def test_array_of_structures(self):
+        import gc
+        gc.collect()
+        gc.collect()
+        gc.collect()
+        from _rawffi import _num_of_allocated_objects as _num
+        assert _num() == 3
         class X(Structure):
             _fields_ = [('x', c_int), ('y', c_int)]
 
@@ -120,4 +128,4 @@
         x.y = 3
         y[1] = x
         assert y[1].y == 3
-    
+        

Modified: pypy/dist/pypy/lib/app_test/ctypes/test_keepalive.py
==============================================================================
--- pypy/dist/pypy/lib/app_test/ctypes/test_keepalive.py	(original)
+++ pypy/dist/pypy/lib/app_test/ctypes/test_keepalive.py	Mon Feb 18 15:54:42 2008
@@ -73,4 +73,4 @@
         a[3].p = pointer(s)
 
         assert a._objects['0:3']['1'] is s
-        
+

Modified: pypy/dist/pypy/lib/app_test/ctypes/test_unions.py
==============================================================================
--- pypy/dist/pypy/lib/app_test/ctypes/test_unions.py	(original)
+++ pypy/dist/pypy/lib/app_test/ctypes/test_unions.py	Mon Feb 18 15:54:42 2008
@@ -1,7 +1,8 @@
 
 from ctypes import *
+from support import BaseCTypesTestChecker
 
-class TestUnion:
+class TestUnion(BaseCTypesTestChecker):
     def test_getattr(self):
         class Stuff(Union):
             _fields_ = [('x', c_char), ('y', c_int)]



More information about the Pypy-commit mailing list