[pypy-svn] r78445 - in pypy/branch/fast-forward/pypy/module/_io: . test

afa at codespeak.net afa at codespeak.net
Fri Oct 29 10:42:14 CEST 2010


Author: afa
Date: Fri Oct 29 10:42:13 2010
New Revision: 78445

Modified:
   pypy/branch/fast-forward/pypy/module/_io/interp_iobase.py
   pypy/branch/fast-forward/pypy/module/_io/test/test_io.py
Log:
implement abstract tell() == seek(0, 1)


Modified: pypy/branch/fast-forward/pypy/module/_io/interp_iobase.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/_io/interp_iobase.py	(original)
+++ pypy/branch/fast-forward/pypy/module/_io/interp_iobase.py	Fri Oct 29 10:42:13 2010
@@ -74,6 +74,10 @@
                 space.wrap("I/O operation on closed file"))
 
     @unwrap_spec('self', ObjSpace)
+    def tell_w(self, space):
+        return space.call_method(self, "seek", space.wrap(0), space.wrap(1))
+
+    @unwrap_spec('self', ObjSpace)
     def enter_w(self, space):
         self._check_closed(space)
         return space.wrap(self)
@@ -225,6 +229,7 @@
     next = interp2app(W_IOBase.next_w),
     close = interp2app(W_IOBase.close_w),
     flush = interp2app(W_IOBase.flush_w),
+    tell = interp2app(W_IOBase.tell_w),
     isatty = interp2app(W_IOBase.isatty_w),
     readable = interp2app(W_IOBase.readable_w),
     writable = interp2app(W_IOBase.writable_w),

Modified: pypy/branch/fast-forward/pypy/module/_io/test/test_io.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/_io/test/test_io.py	(original)
+++ pypy/branch/fast-forward/pypy/module/_io/test/test_io.py	Fri Oct 29 10:42:13 2010
@@ -71,6 +71,13 @@
         import gc; gc.collect()
         assert record == [1, 2, 3]
 
+    def test_tell(self):
+        import io
+        class MyIO(io.IOBase):
+            def seek(self, pos, whence=0):
+                return 42
+        assert MyIO().tell() == 42
+
 class AppTestOpen:
     def setup_class(cls):
         tmpfile = udir.join('tmpfile').ensure()



More information about the Pypy-commit mailing list