Description
Even though I'm well aware of the nursery
fixture's behavior of cancelling the nursery when the test function reaches end of scope, too many times I've written invalid tests that silently end without completing the test code. This is the worst kind of trap for test authors.
- example (my error): groove-x/trio-util@44ea836
- example (PR contributor's error): Catch ClosedResourceError. Fixes #134 trio-websocket#140 (comment)
In hindsight, it would have been better for the nursery
fixture to not automatically cancel. The test writer would have to cancel explicitly, and the utility of the fixture is simply to avoid boilerplate and extra nesting. The big advantage is that the failure mode when the test author does the wrong thing is obvious: the test will hang.
At this point, changing the nursery
semantics would break the world and cause confusion. So perhaps the best we can do is add a fixture under another name, like simple_nursery
.