[pypy-commit] pypy py3k: (antocuni, arigo): we no longer have a file to subclass in py3k. Change the test to use array.array, and add a comment explaining what we are actually testing

antocuni noreply at buildbot.pypy.org
Tue Feb 21 11:36:52 CET 2012


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: py3k
Changeset: r52719:94f6f187a675
Date: 2012-02-21 11:36 +0100
http://bitbucket.org/pypy/pypy/changeset/94f6f187a675/

Log:	(antocuni, arigo): we no longer have a file to subclass in py3k.
	Change the test to use array.array, and add a comment explaining
	what we are actually testing

diff --git a/pypy/interpreter/test/test_typedef.py b/pypy/interpreter/test/test_typedef.py
--- a/pypy/interpreter/test/test_typedef.py
+++ b/pypy/interpreter/test/test_typedef.py
@@ -313,20 +313,22 @@
         cls.w_path = cls.space.wrap(str(path))
 
     def test_destructor(self):
-        import gc, os
+        import gc, array
         seen = []
-        class MyFile(file):
+        class MyArray(array.array):
             def __del__(self):
+                # here we check that we can still access the array, i.e. that
+                # the interp-level __del__ has not been called yet
                 seen.append(10)
-                seen.append(os.lseek(self.fileno(), 2, 0))
-        f = MyFile(self.path, 'r')
-        fd = f.fileno()
-        seen.append(os.lseek(fd, 5, 0))
-        del f
+                seen.append(self[0])
+        a = MyArray('i')
+        a.append(42)
+        seen.append(a[0])
+        del a
         gc.collect(); gc.collect(); gc.collect()
         lst = seen[:]
-        assert lst == [5, 10, 2]
-        raises(OSError, os.lseek, fd, 7, 0)
+        print(lst)
+        assert lst == [42, 10, 42]
 
     def test_method_attrs(self):
         import sys


More information about the pypy-commit mailing list