diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-02-11 11:11:44 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-02-11 11:11:44 (GMT) |
commit | 94a619d48b90aba5b5b42004e84b290bb68f0664 (patch) | |
tree | fc77c9566191d8597af0be96f17a0b6d5bf82f45 /Lib/test/test_io.py | |
parent | e93b06a0a3255026802be19de249b3fdfe955b96 (diff) | |
download | cpython-94a619d48b90aba5b5b42004e84b290bb68f0664.zip cpython-94a619d48b90aba5b5b42004e84b290bb68f0664.tar.gz cpython-94a619d48b90aba5b5b42004e84b290bb68f0664.tar.bz2 |
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.py | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py index 28f440d..86440c5 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) |