Skip to content

Commit cd918c2

Browse files
sobolevnpicnixz
andauthored
Apply suggestions from code review
Co-authored-by: Bénédikt Tran <[email protected]>
1 parent 6862fb4 commit cd918c2

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

Lib/test/test_asyncgen.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,20 +1172,21 @@ async def run():
11721172
def test_sync_anext_raises_exception(self):
11731173
# See: https://github.com/python/cpython/issues/131670
11741174
msg = 'custom'
1175-
for exc in [
1176-
StopAsyncIteration(msg),
1177-
StopIteration(msg),
1178-
ValueError(msg),
1179-
Exception(msg),
1175+
for exc_type in [
1176+
StopAsyncIteration,
1177+
StopIteration,
1178+
ValueError,
1179+
Exception,
11801180
]:
1181+
exc = exc_type(msg)
11811182
with self.subTest(exc=exc):
11821183
class A:
11831184
def __anext__(self):
11841185
raise exc
11851186

1186-
with self.assertRaisesRegex(type(exc), msg):
1187+
with self.assertRaisesRegex(exc_type, msg):
11871188
anext(A())
1188-
with self.assertRaisesRegex(type(exc), msg):
1189+
with self.assertRaisesRegex(exc_type, msg):
11891190
anext(A(), 1)
11901191

11911192
def test_async_gen_asyncio_anext_stopiteration(self):
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
Fix :func:`anext` failing on sync :meth:`~object.__anext__` that raises
2-
:exc:`StopAsyncIteration`.
1+
Fix :func:`anext` failing on sync :meth:`~object.__anext__` raising an exception.

0 commit comments

Comments
 (0)