Skip to content

Commit 8b701d6

Browse files
authored
Merge pull request #6 from iritkatriel/pr96428
assert that deprecation warning is emitted
2 parents 31b2e9f + 0e56eb9 commit 8b701d6

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

Lib/test/test_asyncgen.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,7 @@ def test_async_gen_3_arg_deprecation_warning(self):
382382
async def gen():
383383
yield 123
384384

385-
with warnings.catch_warnings():
386-
warnings.filterwarnings("ignore", category=DeprecationWarning)
385+
with self.assertWarns(DeprecationWarning):
387386
gen().athrow(GeneratorExit, GeneratorExit(), None)
388387

389388
def test_async_gen_api_01(self):

Lib/test/test_asyncio/test_futures.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,8 @@ def test_future_stop_iteration_args(self):
620620
def test_future_iter_throw(self):
621621
fut = self._new_future(loop=self.loop)
622622
fi = iter(fut)
623+
with self.assertWarns(DeprecationWarning):
624+
fi.throw(Exception, Exception("zebra"), None)
623625
with warnings.catch_warnings():
624626
warnings.filterwarnings("ignore", category=DeprecationWarning)
625627
self.assertRaises(TypeError, fi.throw,

Lib/test/test_coroutines.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,13 @@ async def foo():
712712
aw.throw(ZeroDivisionError())
713713
self.assertEqual(N, 102)
714714

715+
coro = foo()
716+
aw = coro.__await__()
717+
next(aw)
718+
with self.assertRaises(ZeroDivisionError):
719+
with self.assertWarns(DeprecationWarning):
720+
aw.throw(ZeroDivisionError, ZeroDivisionError(), None)
721+
715722
def test_func_11(self):
716723
async def func(): pass
717724
coro = func()

Lib/test/test_generators.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,15 @@ def generator():
342342
with self.assertRaises(StopIteration):
343343
gen.throw(E)
344344

345+
def test_gen_3_arg_deprecation_warning(self):
346+
def g():
347+
yield 42
348+
349+
gen = g()
350+
with self.assertWarns(DeprecationWarning):
351+
with self.assertRaises(TypeError):
352+
gen.throw(TypeError, TypeError(24), None)
353+
345354
def test_stopiteration_error(self):
346355
# See also PEP 479.
347356

0 commit comments

Comments
 (0)