[pypy-svn] r78737 - in pypy/branch/fast-forward: lib-python/2.7.0/test pypy/module/_io
afa at codespeak.net
afa at codespeak.net
Fri Nov 5 14:03:49 CET 2010
Author: afa
Date: Fri Nov 5 14:03:48 2010
New Revision: 78737
Modified:
pypy/branch/fast-forward/lib-python/2.7.0/test/test_fileio.py
pypy/branch/fast-forward/pypy/module/_io/interp_fileio.py
Log:
This should fix all remaining issues in test_fileio.py
Modified: pypy/branch/fast-forward/lib-python/2.7.0/test/test_fileio.py
==============================================================================
--- pypy/branch/fast-forward/lib-python/2.7.0/test/test_fileio.py (original)
+++ pypy/branch/fast-forward/lib-python/2.7.0/test/test_fileio.py Fri Nov 5 14:03:48 2010
@@ -12,6 +12,7 @@
from test.test_support import TESTFN, check_warnings, run_unittest, make_bad_fd
from test.test_support import py3k_bytes as bytes
+from test.test_support import gc_collect
from test.script_helper import run_python
from _io import FileIO as _FileIO
@@ -34,6 +35,7 @@
self.assertEquals(self.f.tell(), p.tell())
self.f.close()
self.f = None
+ gc_collect()
self.assertRaises(ReferenceError, getattr, p, 'tell')
def testSeekTell(self):
@@ -104,8 +106,8 @@
self.assertTrue(f.closed)
def testMethods(self):
- methods = ['fileno', 'isatty', 'read', 'readinto',
- 'seek', 'tell', 'truncate', 'write', 'seekable',
+ methods = ['fileno', 'isatty', 'read',
+ 'tell', 'truncate', 'seekable',
'readable', 'writable']
if sys.platform.startswith('atheos'):
methods.remove('truncate')
@@ -117,6 +119,10 @@
method = getattr(self.f, methodname)
# should raise on closed file
self.assertRaises(ValueError, method)
+ # methods with one argument
+ self.assertRaises(ValueError, self.f.readinto, 0)
+ self.assertRaises(ValueError, self.f.write, 0)
+ self.assertRaises(ValueError, self.f.seek, 0)
def testOpendir(self):
# Issue 3703: opening a directory should fill the errno
Modified: pypy/branch/fast-forward/pypy/module/_io/interp_fileio.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/_io/interp_fileio.py (original)
+++ pypy/branch/fast-forward/pypy/module/_io/interp_fileio.py Fri Nov 5 14:03:48 2010
@@ -217,13 +217,13 @@
def _check_readable(self, space):
if not self.readable:
raise OperationError(
- space.w_IOError,
+ space.w_ValueError,
space.wrap("file not open for reading"))
def _check_writable(self, space):
if not self.writable:
raise OperationError(
- space.w_IOError,
+ space.w_ValueError,
space.wrap("file not open for writing"))
def _close(self, space):
More information about the Pypy-commit
mailing list