Skip to content

Commit e79162d

Browse files
committed
Fix the last remaining test.
1 parent e9ac731 commit e79162d

1 file changed

Lines changed: 33 additions & 33 deletions

File tree

Lib/test/test_async_yield_from.py

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import inspect
99
from functools import partial
1010

11-
from test.support import captured_stderr, disable_gc, gc_collect, run_yielding_async_fn
11+
from test.support import captured_stderr, disable_gc, gc_collect, run_yielding_async_fn, catch_unraisable_exception
1212

1313
_async_test = partial(partial, run_yielding_async_fn)
1414

@@ -554,38 +554,38 @@ async def g():
554554
"finishing g",
555555
])
556556

557-
# @_async_test
558-
# async def test_broken_getattr_handling(self):
559-
# """
560-
# Test subiterator with a broken getattr implementation
561-
# """
562-
# class Broken:
563-
# def __aiter__(self):
564-
# return self
565-
# async def __anext__(self):
566-
# return 1
567-
# async def __getattr__(self, attr):
568-
# 1/0
569-
570-
# async def g():
571-
# async yield from Broken()
572-
573-
# with self.assertRaises(ZeroDivisionError):
574-
# gi = g()
575-
# self.assertEqual(await anext(gi), 1)
576-
# await gi.asend(1)
577-
578-
# with self.assertRaises(ZeroDivisionError):
579-
# gi = g()
580-
# self.assertEqual(await anext(gi), 1)
581-
# await gi.athrow(AttributeError)
582-
583-
# with support.catch_unraisable_exception() as cm:
584-
# gi = g()
585-
# self.assertEqual(await anext(gi), 1)
586-
# await gi.aclose()
587-
588-
# self.assertEqual(ZeroDivisionError, cm.unraisable.exc_type)
557+
@_async_test
558+
async def test_broken_getattr_handling(self):
559+
"""
560+
Test subiterator with a broken getattr implementation
561+
"""
562+
class Broken:
563+
def __aiter__(self):
564+
return self
565+
async def __anext__(self):
566+
return 1
567+
def __getattr__(self, attr):
568+
1/0
569+
570+
async def g():
571+
async yield from Broken()
572+
573+
with self.assertRaises(ZeroDivisionError):
574+
gi = g()
575+
self.assertEqual(await anext(gi), 1)
576+
await gi.asend(1)
577+
578+
with self.assertRaises(ZeroDivisionError):
579+
gi = g()
580+
self.assertEqual(await anext(gi), 1)
581+
await gi.athrow(AttributeError)
582+
583+
with catch_unraisable_exception() as cm:
584+
gi = g()
585+
self.assertEqual(await anext(gi), 1)
586+
await gi.aclose()
587+
588+
self.assertEqual(ZeroDivisionError, cm.unraisable.exc_type)
589589

590590
@_async_test
591591
async def test_exception_in_initial_next_call(self):

0 commit comments

Comments
 (0)