Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Lib/test/test_asyncgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,7 @@ def test_async_gen_3_arg_deprecation_warning(self):
async def gen():
yield 123

with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
with self.assertWarns(DeprecationWarning):
gen().athrow(GeneratorExit, GeneratorExit(), None)

def test_async_gen_api_01(self):
Expand Down
2 changes: 2 additions & 0 deletions Lib/test/test_asyncio/test_futures.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,8 @@ def test_future_stop_iteration_args(self):
def test_future_iter_throw(self):
fut = self._new_future(loop=self.loop)
fi = iter(fut)
with self.assertWarns(DeprecationWarning):
fi.throw(Exception, Exception("zebra"), None)
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
self.assertRaises(TypeError, fi.throw,
Expand Down
7 changes: 7 additions & 0 deletions Lib/test/test_coroutines.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,13 @@ async def foo():
aw.throw(ZeroDivisionError())
self.assertEqual(N, 102)

coro = foo()
aw = coro.__await__()
next(aw)
with self.assertRaises(ZeroDivisionError):
with self.assertWarns(DeprecationWarning):
aw.throw(ZeroDivisionError, ZeroDivisionError(), None)

def test_func_11(self):
async def func(): pass
coro = func()
Expand Down
9 changes: 9 additions & 0 deletions Lib/test/test_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,15 @@ def generator():
with self.assertRaises(StopIteration):
gen.throw(E)

def test_gen_3_arg_deprecation_warning(self):
def g():
yield 42

gen = g()
with self.assertWarns(DeprecationWarning):
with self.assertRaises(TypeError):
gen.throw(TypeError, TypeError(24), None)

def test_stopiteration_error(self):
# See also PEP 479.

Expand Down