mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Issue #5761: Add the name of the underlying file to the repr() of various IO objects.
This commit is contained in:
parent
744af44064
commit
716c444edc
7 changed files with 107 additions and 14 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue