summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_fileio.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-12-02 21:39:56 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-12-02 21:39:56 (GMT)
commit4954f9fcab59e38f2229998b3276567d4bf92b53 (patch)
tree5f0e1732e20489b9a6843ba6e742e9a84a393c49 /Lib/test/test_fileio.py
parentb16edc8087586699e775d6fa6b20d750e9916fff (diff)
downloadcpython-4954f9fcab59e38f2229998b3276567d4bf92b53.zip
cpython-4954f9fcab59e38f2229998b3276567d4bf92b53.tar.gz
cpython-4954f9fcab59e38f2229998b3276567d4bf92b53.tar.bz2
Issue #17401: Output the closefd attribute as boolean.
Diffstat (limited to 'Lib/test/test_fileio.py')
-rw-r--r--Lib/test/test_fileio.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/Lib/test/test_fileio.py b/Lib/test/test_fileio.py
index 7c1a5ce..743ca5c 100644
--- a/Lib/test/test_fileio.py
+++ b/Lib/test/test_fileio.py
@@ -113,15 +113,25 @@ class AutoFileTests(unittest.TestCase):
def testRepr(self):
self.assertEqual(
- repr(self.f), "<_io.FileIO name=%r mode=%r closefd='%d'>"
- % (self.f.name, self.f.mode, self.f.closefd))
+ repr(self.f), "<_io.FileIO name=%r mode=%r closefd=True>"
+ % (self.f.name, self.f.mode))
del self.f.name
self.assertEqual(
- repr(self.f), "<_io.FileIO fd=%r mode=%r closefd='%d'>"
- % (self.f.fileno(), self.f.mode, self.f.closefd))
+ repr(self.f), "<_io.FileIO fd=%r mode=%r closefd=True>"
+ % (self.f.fileno(), self.f.mode))
self.f.close()
self.assertEqual(repr(self.f), "<_io.FileIO [closed]>")
+ def testReprNoCloseFD(self):
+ fd = os.open(TESTFN, os.O_RDONLY)
+ try:
+ with _FileIO(fd, 'r', closefd=False) as f:
+ self.assertEqual(repr(f),
+ "<_io.FileIO name=%r mode=%r closefd=False>"
+ % (f.name, f.mode))
+ finally:
+ os.close(fd)
+
def testErrors(self):
f = self.f
self.assertTrue(not f.isatty())