Issue #5761: Add the name of the underlying file to the repr() of various IO objects.

This commit is contained in:
Antoine Pitrou 2009-05-23 19:04:03 +00:00
parent 744af44064
commit 716c444edc
7 changed files with 107 additions and 14 deletions

View file

@ -70,9 +70,13 @@ class AutoFileTests(unittest.TestCase):
self.assertEquals(array('b', [1, 2]), a[:n])
def testRepr(self):
self.assertEquals(repr(self.f),
"io.FileIO(%d, %s)" % (self.f.fileno(),
repr(self.f.mode)))
self.assertEquals(repr(self.f), "<_io.FileIO name=%r mode=%r>"
% (self.f.name, self.f.mode))
del self.f.name
self.assertEquals(repr(self.f), "<_io.FileIO fd=%r mode=%r>"
% (self.f.fileno(), self.f.mode))
self.f.close()
self.assertEquals(repr(self.f), "<_io.FileIO [closed]>")
def testErrors(self):
f = self.f