summaryrefslogtreecommitdiff
path: root/Lib/test/test_io.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-02-11 13:12:19 +0200
committerSerhiy Storchaka <storchaka@gmail.com>2016-02-11 13:12:19 +0200
commit2feb64258558fc280f1d87bec211d83def48a9f0 (patch)
treed370a07dff4adfca5ba740cbdf603d7b6b31c9c1 /Lib/test/test_io.py
parent885bdc4946890f4bb80557fab80c3874b2cc4d39 (diff)
parent94a619d48b90aba5b5b42004e84b290bb68f0664 (diff)
downloadcpython-git-2feb64258558fc280f1d87bec211d83def48a9f0.tar.gz
Issue #26325: Added test.support.check_no_resource_warning() to check that
no ResourceWarning is emitted.
Diffstat (limited to 'Lib/test/test_io.py')
-rw-r--r--Lib/test/test_io.py12
1 files changed, 3 insertions, 9 deletions
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
index 28f440d91a..86440c5b39 100644
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -681,18 +681,14 @@ class IOTest(unittest.TestCase):
f2.readline()
def test_nonbuffered_textio(self):
- with warnings.catch_warnings(record=True) as recorded:
+ with support.check_no_resource_warning(self):
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 support.check_no_resource_warning(self):
with self.assertRaises(ValueError):
self.open(support.TESTFN, 'w', newline='invalid')
- support.gc_collect()
- self.assertEqual(recorded, [])
class CIOTest(IOTest):
@@ -3366,10 +3362,8 @@ class MiscIOTest(unittest.TestCase):
# When using closefd=False, there's no warning
r, w = os.pipe()
fds += r, w
- with warnings.catch_warnings(record=True) as recorded:
+ with support.check_no_resource_warning(self):
open(r, *args, closefd=False, **kwargs)
- support.gc_collect()
- self.assertEqual(recorded, [])
def test_warn_on_dealloc_fd(self):
self._check_warn_on_dealloc_fd("rb", buffering=0)