summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_io.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2019-05-24 22:09:38 (GMT)
committerGitHub <noreply@github.com>2019-05-24 22:09:38 (GMT)
commit6dbbe748e101a173b4cff8aada41e9313e287e0f (patch)
treeb0361e58e666c57fd742d44b30c5bf72e98c090b /Lib/test/test_io.py
parenta9f05d69ccbf3c75cdd604c25094282697789a62 (diff)
downloadcpython-6dbbe748e101a173b4cff8aada41e9313e287e0f.zip
cpython-6dbbe748e101a173b4cff8aada41e9313e287e0f.tar.gz
cpython-6dbbe748e101a173b4cff8aada41e9313e287e0f.tar.bz2
bpo-36829: Document test.support.catch_unraisable_exception() (GH-13554)
catch_unraisable_exception() now also removes its 'unraisable' attribute at the context manager exit.
Diffstat (limited to 'Lib/test/test_io.py')
-rw-r--r--Lib/test/test_io.py20
1 files changed, 6 insertions, 14 deletions
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
index 6f22b35..3a1f5ba 100644
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -1098,18 +1098,14 @@ class CommonBufferedTests:
# Test that the exception state is not modified by a destructor,
# even if close() fails.
rawio = self.CloseFailureIO()
- try:
- with support.catch_unraisable_exception() as cm:
- with self.assertRaises(AttributeError):
- self.tp(rawio).xyzzy
+ with support.catch_unraisable_exception() as cm:
+ with self.assertRaises(AttributeError):
+ self.tp(rawio).xyzzy
if not IOBASE_EMITS_UNRAISABLE:
self.assertIsNone(cm.unraisable)
elif cm.unraisable is not None:
self.assertEqual(cm.unraisable.exc_type, OSError)
- finally:
- # Explicitly break reference cycle
- cm = None
def test_repr(self):
raw = self.MockRawIO()
@@ -2854,18 +2850,14 @@ class TextIOWrapperTest(unittest.TestCase):
# Test that the exception state is not modified by a destructor,
# even if close() fails.
rawio = self.CloseFailureIO()
- try:
- with support.catch_unraisable_exception() as cm:
- with self.assertRaises(AttributeError):
- self.TextIOWrapper(rawio).xyzzy
+ with support.catch_unraisable_exception() as cm:
+ with self.assertRaises(AttributeError):
+ self.TextIOWrapper(rawio).xyzzy
if not IOBASE_EMITS_UNRAISABLE:
self.assertIsNone(cm.unraisable)
elif cm.unraisable is not None:
self.assertEqual(cm.unraisable.exc_type, OSError)
- finally:
- # Explicitly break reference cycle
- cm = None
# Systematic tests of the text I/O API