@@ -133,11 +133,16 @@ class TrioTestContext:
133133 def __init__ (self ):
134134 self .crashed = False
135135 self .test_cancel_scope = None
136+ self .fixtures_with_errors = set ()
137+ self .fixtures_with_cancel = set ()
136138 self .error_list = []
137139
138- def crash (self , exc ):
139- if exc is not None :
140+ def crash (self , fixture , exc ):
141+ if exc is None :
142+ self .fixtures_with_cancel .add (fixture )
143+ else :
140144 self .error_list .append (exc )
145+ self .fixtures_with_errors .add (fixture )
141146 self .crashed = True
142147 if self .test_cancel_scope is not None :
143148 self .test_cancel_scope .cancel ()
@@ -193,7 +198,7 @@ async def _fixture_manager(self, test_ctx):
193198 finally :
194199 nursery_fixture .cancel_scope .cancel ()
195200 except BaseException as exc :
196- test_ctx .crash (exc )
201+ test_ctx .crash (self , exc )
197202 finally :
198203 self .setup_done .set ()
199204 self ._teardown_done .set ()
@@ -286,7 +291,7 @@ async def run(self, test_ctx, contextvars_ctx):
286291 except BaseException as exc :
287292 assert isinstance (exc , trio .Cancelled )
288293 yield_outcome = outcome .Error (exc )
289- test_ctx .crash (None )
294+ test_ctx .crash (self , None )
290295 with trio .CancelScope (shield = True ):
291296 for event in self .user_done_events :
292297 await event .wait ()
@@ -342,6 +347,19 @@ async def _bootstrap_fixtures_and_run_test(**kwargs):
342347 fixture .run , test_ctx , contextvars_ctx , name = fixture .name
343348 )
344349
350+ silent_cancellers = (
351+ test_ctx .fixtures_with_cancel - test_ctx .fixtures_with_errors
352+ )
353+ if silent_cancellers :
354+ for fixture in silent_cancellers :
355+ test_ctx .error_list .append (
356+ RuntimeError (
357+ "{} cancelled the test but didn't "
358+ "raise an error"
359+ .format (fixture .name )
360+ )
361+ )
362+
345363 if test_ctx .error_list :
346364 raise trio .MultiError (test_ctx .error_list )
347365
0 commit comments