bpo-39101: Fixes BaseException hang in IsolatedAsyncioTestCase. (GH-22654)

(cherry picked from commit 8374d2ee15)

Co-authored-by: Lisa Roach <lisaroach14@gmail.com>
This commit is contained in:
Miss Islington (bot) 2020-12-16 09:56:10 -08:00 committed by GitHub
parent 7492b55ea0
commit 9d409d6b47
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 2 deletions

View file

@ -190,6 +190,33 @@ async def on_async_cleanup(self, val):
'async_cleanup 2',
'sync_cleanup 1'])
def test_base_exception_from_async_method(self):
events = []
class Test(unittest.IsolatedAsyncioTestCase):
async def test_base(self):
events.append("test_base")
raise BaseException()
events.append("not it")
async def test_no_err(self):
events.append("test_no_err")
async def test_cancel(self):
raise asyncio.CancelledError()
test = Test("test_base")
output = test.run()
self.assertFalse(output.wasSuccessful())
test = Test("test_no_err")
test.run()
self.assertEqual(events, ['test_base', 'test_no_err'])
test = Test("test_cancel")
output = test.run()
self.assertFalse(output.wasSuccessful())
if __name__ == "__main__":
unittest.main()