@@ -458,7 +458,7 @@ def test_async_yield_fixture(testdir, cmd_opts):
458
458
459
459
@pytest_twisted.async_yield_fixture(
460
460
scope="function",
461
- params=["fs", "imap", "web", "gopher", " archie"],
461
+ params=["fs", "imap", "web", "archie"],
462
462
)
463
463
async def foo(request):
464
464
d1, d2 = defer.Deferred(), defer.Deferred()
@@ -471,9 +471,6 @@ async def foo(request):
471
471
# https://github.com/twisted/twisted/blob/c0f1394c7bfb04d97c725a353a1f678fa6a1c602/src/twisted/internet/defer.py#L459
472
472
yield d2,
473
473
474
- if request.param == "gopher":
475
- raise RuntimeError("gaz")
476
-
477
474
if request.param == "archie":
478
475
yield 42
479
476
@@ -486,7 +483,34 @@ def test_succeed(foo):
486
483
testdir .makepyfile (test_file )
487
484
rr = testdir .run (* cmd_opts , timeout = timeout )
488
485
# TODO: this is getting super imprecise...
489
- assert_outcomes (rr , {"passed" : 4 , "failed" : 1 , "errors" : 2 })
486
+ assert_outcomes (rr , {"passed" : 3 , "failed" : 1 , "errors" : 1 })
487
+
488
+
489
+ @skip_if_no_async_generators ()
490
+ def test_async_yield_fixture_teardown_exception (testdir , cmd_opts ):
491
+ test_file = """
492
+ from twisted.internet import reactor, defer
493
+ import pytest
494
+ import pytest_twisted
495
+
496
+ class UniqueLocalException(Exception):
497
+ pass
498
+
499
+ @pytest_twisted.async_yield_fixture()
500
+ async def foo(request):
501
+ yield 13
502
+
503
+ raise UniqueLocalException("some message")
504
+
505
+ @pytest_twisted.ensureDeferred
506
+ async def test_succeed(foo):
507
+ assert foo == 13
508
+ """
509
+
510
+ testdir .makepyfile (test_file )
511
+ rr = testdir .run (* cmd_opts , timeout = timeout )
512
+ rr .stdout .fnmatch_lines (lines2 = ["E*.UniqueLocalException: some message*" ])
513
+ assert_outcomes (rr , {"passed" : 1 , "errors" : 1 })
490
514
491
515
492
516
@skip_if_no_async_generators ()
0 commit comments