summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_io.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-06-09 10:32:34 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-06-09 10:32:34 (GMT)
commitf10063e3c3dcd5fe5b99858fc618c574b6df7bf2 (patch)
treed549bcb1c89abdf86860b884f96b06c3aa846da9 /Lib/test/test_io.py
parent8a8f7f983099f172d1f7c25d4fd99f5c0eb14072 (diff)
downloadcpython-f10063e3c3dcd5fe5b99858fc618c574b6df7bf2.zip
cpython-f10063e3c3dcd5fe5b99858fc618c574b6df7bf2.tar.gz
cpython-f10063e3c3dcd5fe5b99858fc618c574b6df7bf2.tar.bz2
Issue #21310: Fixed possible resource leak in failed open().
Diffstat (limited to 'Lib/test/test_io.py')
-rw-r--r--Lib/test/test_io.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
index a94b85a..1cf97dd 100644
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -653,6 +653,20 @@ class IOTest(unittest.TestCase):
fileio.close()
f2.readline()
+ def test_nonbuffered_textio(self):
+ with warnings.catch_warnings(record=True) as recorded:
+ with self.assertRaises(ValueError):
+ self.open(support.TESTFN, 'w', buffering=0)
+ support.gc_collect()
+ self.assertEqual(recorded, [])
+
+ def test_invalid_newline(self):
+ with warnings.catch_warnings(record=True) as recorded:
+ with self.assertRaises(ValueError):
+ self.open(support.TESTFN, 'w', newline='invalid')
+ support.gc_collect()
+ self.assertEqual(recorded, [])
+
class CIOTest(IOTest):