summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_io.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-06-09 10:35:43 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-06-09 10:35:43 (GMT)
commit3a56117a60ef71709c9a779bfae8b8793600c513 (patch)
tree0aadd6e84ebf1652f4d3e0bbc6124f139b6adda8 /Lib/test/test_io.py
parent047f14c3c6ed39371fab2d93db8dfd5b5fdb06f1 (diff)
parentf10063e3c3dcd5fe5b99858fc618c574b6df7bf2 (diff)
downloadcpython-3a56117a60ef71709c9a779bfae8b8793600c513.zip
cpython-3a56117a60ef71709c9a779bfae8b8793600c513.tar.gz
cpython-3a56117a60ef71709c9a779bfae8b8793600c513.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 3c2c102..eef100f 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):