Adjust aio test for silent cancellation by parent
							parent
							
								
									6aa780d0cd
								
							
						
					
					
						commit
						8bd4db150b
					
				|  | @ -15,6 +15,7 @@ import tractor | ||||||
| from tractor import ( | from tractor import ( | ||||||
|     to_asyncio, |     to_asyncio, | ||||||
|     RemoteActorError, |     RemoteActorError, | ||||||
|  |     ContextCancelled, | ||||||
| ) | ) | ||||||
| from tractor.trionics import BroadcastReceiver | from tractor.trionics import BroadcastReceiver | ||||||
| 
 | 
 | ||||||
|  | @ -224,14 +225,23 @@ def test_context_spawns_aio_task_that_errors( | ||||||
| 
 | 
 | ||||||
|                     await trio.sleep_forever() |                     await trio.sleep_forever() | ||||||
| 
 | 
 | ||||||
|     with pytest.raises(RemoteActorError) as excinfo: |         return await ctx.result() | ||||||
|  | 
 | ||||||
|  |     if parent_cancels: | ||||||
|  |         # bc the parent made the cancel request, | ||||||
|  |         # the error is not raised locally but instead | ||||||
|  |         # the context is exited silently | ||||||
|  |         res = trio.run(main) | ||||||
|  |         assert isinstance(res, ContextCancelled) | ||||||
|  |         assert 'root' in res.canceller[0] | ||||||
|  | 
 | ||||||
|  |     else: | ||||||
|  |         expect = RemoteActorError | ||||||
|  |         with pytest.raises(expect) as excinfo: | ||||||
|             trio.run(main) |             trio.run(main) | ||||||
| 
 | 
 | ||||||
|         err = excinfo.value |         err = excinfo.value | ||||||
|     assert isinstance(err, RemoteActorError) |         assert isinstance(err, expect) | ||||||
|     if parent_cancels: |  | ||||||
|         assert err.type == trio.Cancelled |  | ||||||
|     else: |  | ||||||
|         assert err.type == AssertionError |         assert err.type == AssertionError | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue