summaryrefslogtreecommitdiff
path: root/Lib/test/test_asyncio/test_futures2.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_asyncio/test_futures2.py')
-rw-r--r--Lib/test/test_asyncio/test_futures2.py31
1 files changed, 30 insertions, 1 deletions
diff --git a/Lib/test/test_asyncio/test_futures2.py b/Lib/test/test_asyncio/test_futures2.py
index 60b5885036..71279b69c7 100644
--- a/Lib/test/test_asyncio/test_futures2.py
+++ b/Lib/test/test_asyncio/test_futures2.py
@@ -1,13 +1,42 @@
# IsolatedAsyncioTestCase based tests
import asyncio
+import traceback
import unittest
+from asyncio import tasks
def tearDownModule():
asyncio.set_event_loop_policy(None)
-class FutureTests(unittest.IsolatedAsyncioTestCase):
+class FutureTests:
+
+ async def test_future_traceback(self):
+
+ async def raise_exc():
+ raise TypeError(42)
+
+ future = self.cls(raise_exc())
+
+ for _ in range(5):
+ try:
+ await future
+ except TypeError as e:
+ tb = ''.join(traceback.format_tb(e.__traceback__))
+ self.assertEqual(tb.count("await future"), 1)
+ else:
+ self.fail('TypeError was not raised')
+
+@unittest.skipUnless(hasattr(tasks, '_CTask'),
+ 'requires the C _asyncio module')
+class CFutureTests(FutureTests, unittest.IsolatedAsyncioTestCase):
+ cls = tasks._CTask
+
+class PyFutureTests(FutureTests, unittest.IsolatedAsyncioTestCase):
+ cls = tasks._PyTask
+
+class FutureReprTests(unittest.IsolatedAsyncioTestCase):
+
async def test_recursive_repr_for_pending_tasks(self):
# The call crashes if the guard for recursive call
# in base_futures:_future_repr_info is absent