diff options
author | rsp4jack <rsp4jack@outlook.com> | 2024-04-04 11:13:32 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-03 20:13:32 -0700 |
commit | 85843348c5f0b8c2f973e8bc586475e69af19cd2 (patch) | |
tree | bff8b37d5662cd05f2bfaca4d54f0eb6a240947a /Lib/test/test_asyncio/test_futures.py | |
parent | b4fe02f595fcb9f78261920a268ef614821ec195 (diff) | |
download | cpython-85843348c5f0b8c2f973e8bc586475e69af19cd2.tar.gz cpython-85843348c5f0b8c2f973e8bc586475e69af19cd2.zip |
gh-117459: Keep the traceback in _convert_future_exc (#117460)
Diffstat (limited to 'Lib/test/test_asyncio/test_futures.py')
-rw-r--r-- | Lib/test/test_asyncio/test_futures.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_futures.py b/Lib/test/test_asyncio/test_futures.py index d3e8efec1c0..458b70451a3 100644 --- a/Lib/test/test_asyncio/test_futures.py +++ b/Lib/test/test_asyncio/test_futures.py @@ -5,6 +5,7 @@ import gc import re import sys import threading +import traceback import unittest from unittest import mock from types import GenericAlias @@ -416,6 +417,24 @@ class BaseFutureTests: _copy_future_state(f_cancelled, newf_cancelled) self.assertTrue(newf_cancelled.cancelled()) + try: + raise concurrent.futures.InvalidStateError + except BaseException as e: + f_exc = e + + f_conexc = self._new_future(loop=self.loop) + f_conexc.set_exception(f_exc) + + newf_conexc = self._new_future(loop=self.loop) + _copy_future_state(f_conexc, newf_conexc) + self.assertTrue(newf_conexc.done()) + try: + newf_conexc.result() + except BaseException as e: + newf_exc = e # assertRaises context manager drops the traceback + newf_tb = ''.join(traceback.format_tb(newf_exc.__traceback__)) + self.assertEqual(newf_tb.count('raise concurrent.futures.InvalidStateError'), 1) + def test_iter(self): fut = self._new_future(loop=self.loop) |