[pypy-svn] r78314 - in pypy/branch/fast-forward/pypy/module/_io: . test
afa at codespeak.net
afa at codespeak.net
Tue Oct 26 19:56:02 CEST 2010
Author: afa
Date: Tue Oct 26 19:56:01 2010
New Revision: 78314
Modified:
pypy/branch/fast-forward/pypy/module/_io/interp_bufferedio.py
pypy/branch/fast-forward/pypy/module/_io/test/test_bufferedio.py
Log:
Test and fix
Modified: pypy/branch/fast-forward/pypy/module/_io/interp_bufferedio.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/_io/interp_bufferedio.py (original)
+++ pypy/branch/fast-forward/pypy/module/_io/interp_bufferedio.py Tue Oct 26 19:56:01 2010
@@ -451,8 +451,8 @@
with self.lock:
- if (not (self.readable and self.read_end == -1) and
- not (self.writable and self.write_end == -1)):
+ if (not (self.readable and self.read_end != -1) and
+ not (self.writable and self.write_end != -1)):
self.pos = 0
self.raw_pos = 0
available = self.buffer_size - self.pos
Modified: pypy/branch/fast-forward/pypy/module/_io/test/test_bufferedio.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/_io/test/test_bufferedio.py (original)
+++ pypy/branch/fast-forward/pypy/module/_io/test/test_bufferedio.py Tue Oct 26 19:56:01 2010
@@ -69,3 +69,33 @@
raises(ValueError, getattr, b, 'closed')
raises(ValueError, b.flush)
raises(ValueError, b.close)
+
+ def test_check_several_writes(self):
+ import _io
+ raw = _io.FileIO(self.tmpfile, 'w')
+ b = _io.BufferedWriter(raw, 13)
+
+ for i in range(4):
+ assert b.write('x' * 10) == 10
+ b.flush()
+ assert self.readfile() == 'x' * 40
+
+ def test_destructor(self):
+ import _io
+
+ record = []
+ class MyIO(_io.BufferedWriter):
+ def __del__(self):
+ record.append(1)
+ super(MyIO, self).__del__()
+ def close(self):
+ record.append(2)
+ super(MyIO, self).close()
+ def flush(self):
+ record.append(3)
+ super(MyIO, self).flush()
+ raw = _io.FileIO(self.tmpfile, 'w')
+ MyIO(raw)
+ import gc; gc.collect()
+ assert record == [1, 2, 3]
+
More information about the Pypy-commit
mailing list