[pypy-svn] pypy default: Fix the test: it's normal for moving gc's to allocate an additional nonmoving buffer,

amauryfa commits-noreply at bitbucket.org
Thu Mar 17 19:55:48 CET 2011


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: 
Changeset: r42771:9ba5088910ee
Date: 2011-03-17 18:05 +0100
http://bitbucket.org/pypy/pypy/changeset/9ba5088910ee/

Log:	Fix the test: it's normal for moving gc's to allocate an additional
	nonmoving buffer, and keep it alive along with the c_char_p object.

diff --git a/lib-python/modified-2.7.0/ctypes/test/test_internals.py b/lib-python/modified-2.7.0/ctypes/test/test_internals.py
--- a/lib-python/modified-2.7.0/ctypes/test/test_internals.py
+++ b/lib-python/modified-2.7.0/ctypes/test/test_internals.py
@@ -29,13 +29,18 @@
         self.assertEqual(refcnt, grc(i))
         self.assertEqual(ci._objects, None)
 
-    @xfail
     def test_c_char_p(self):
         s = "Hello, World"
         refcnt = grc(s)
         cs = c_char_p(s)
         self.assertEqual(refcnt + 1, grc(s))
-        self.assertSame(cs._objects, s)
+        try:
+            # Moving gcs need to allocate a nonmoving buffer
+            cs._objects._obj
+        except AttributeError:
+            self.assertSame(cs._objects, s)
+        else:
+            self.assertSame(cs._objects._obj, s)
 
     def test_simple_struct(self):
         class X(Structure):


More information about the Pypy-commit mailing list