[pypy-svn] r15135 - in pypy/dist/pypy/lib: . test2
arigo at codespeak.net
arigo at codespeak.net
Tue Jul 26 19:28:46 CEST 2005
Author: arigo
Date: Tue Jul 26 19:28:44 2005
New Revision: 15135
Modified:
pypy/dist/pypy/lib/_file.py
pypy/dist/pypy/lib/test2/test_file_extra.py
Log:
Added file.__repr__.
Modified: pypy/dist/pypy/lib/_file.py
==============================================================================
--- pypy/dist/pypy/lib/_file.py (original)
+++ pypy/dist/pypy/lib/_file.py Tue Jul 26 19:28:44 2005
@@ -355,3 +355,10 @@
if self._closed:
raise ValueError('I/O operation on closed file')
return os.isatty(self.fd)
+
+ def __repr__(self):
+ return '<%s file %r, mode %r at 0x%x>' % (
+ self._closed and 'closed' or 'open',
+ self._name,
+ self._mode,
+ id(self))
Modified: pypy/dist/pypy/lib/test2/test_file_extra.py
==============================================================================
--- pypy/dist/pypy/lib/test2/test_file_extra.py (original)
+++ pypy/dist/pypy/lib/test2/test_file_extra.py Tue Jul 26 19:28:44 2005
@@ -24,6 +24,12 @@
for i in range(-1, 10):
assert self.file.readline(i) == cpyfile.readline(i)
+ def test_repr(self):
+ r = repr(self.file)
+ assert r.find('open file') >= 0
+ assert r.find(self.file.name) >= 0
+ assert r.find(self.file.mode) >= 0
+
class TestFdFile(TestFile):
def setup_method(self, method):
import os
More information about the Pypy-commit
mailing list