[pypy-svn] r49415 - in pypy/branch/pypy-interp-file/module/_file: . test

arigo at codespeak.net arigo at codespeak.net
Wed Dec 5 20:31:26 CET 2007


Author: arigo
Date: Wed Dec  5 20:31:25 2007
New Revision: 49415

Modified:
   pypy/branch/pypy-interp-file/module/_file/app_file.py
   pypy/branch/pypy-interp-file/module/_file/interp_file.py
   pypy/branch/pypy-interp-file/module/_file/test/test_file_extra.py
Log:
Many tests pass.  Missing (and untested): truncate(), readinto(), fileno().
Failures in AppTestUniversalNewlines.


Modified: pypy/branch/pypy-interp-file/module/_file/app_file.py
==============================================================================
--- pypy/branch/pypy-interp-file/module/_file/app_file.py	(original)
+++ pypy/branch/pypy-interp-file/module/_file/app_file.py	Wed Dec  5 20:31:25 2007
@@ -248,7 +248,7 @@
         finally:
             self.stream.unlock()
 
-    def flush(self):
+    #def flush(self):
         """flush() -> None.  Flush the internal I/O buffer."""
         if self._closed:
             raise ValueError('I/O operation on closed file')

Modified: pypy/branch/pypy-interp-file/module/_file/interp_file.py
==============================================================================
--- pypy/branch/pypy-interp-file/module/_file/interp_file.py	(original)
+++ pypy/branch/pypy-interp-file/module/_file/interp_file.py	Wed Dec  5 20:31:25 2007
@@ -93,6 +93,9 @@
                 pass
             stream.close()
 
+    def direct_flush(self):
+        self.getstream().flush()
+
     def direct_next(self):
         line = self.getstream().readline()
         if line == '':
@@ -257,9 +260,13 @@
 further I/O operations.  close() may be called more than once without
 error.  Some kinds of file objects (for example, opened by popen())
 may return an exit status upon closing.""")
-        # NB. close() need to use the stream lock to avoid double-closes or
+        # NB. close() needs to use the stream lock to avoid double-closes or
         # close-while-another-thread-uses-it.
 
+
+    _decl(locals(), "flush", ['self'],
+        """flush() -> None.  Flush the internal I/O buffer.""")
+
     _decl(locals(), "isatty", ['self'],
         """isatty() -> true or false.  True if the file is connected to a tty device.""")
 

Modified: pypy/branch/pypy-interp-file/module/_file/test/test_file_extra.py
==============================================================================
--- pypy/branch/pypy-interp-file/module/_file/test/test_file_extra.py	(original)
+++ pypy/branch/pypy-interp-file/module/_file/test/test_file_extra.py	Wed Dec  5 20:31:25 2007
@@ -417,6 +417,7 @@
         f.close()
 
     def test_flush(self):
+        import os
         fn = self.temptestfile
         f = file(fn, 'w', 0)
         f.write('x')
@@ -447,7 +448,7 @@
         f.close()
         assert os.stat(fn).st_size == 3
 
-    def test_isatty():
+    def test_isatty(self):
         try:
             f = file('/dev/tty')
         except IOError:


More information about the pypy-svn mailing list