Repository navigation
Refactor tests in the light of backend auto-detection - #615
Conversation
|
Okay, I've moved things around a bit more so that:
|
| @@ -7,7 +7,7 @@ | |||
|
|
|||
| async def test_get(server, backend): | |||
There was a problem hiding this comment.
Can also remove the backend fixture param from all these test functions since it's not being referenced anywhere.
There was a problem hiding this comment.
Thanks, but actually we can’t — even though we don’t use the backend fixture in the test it’s responsible for setting up the asyncio/trio environment. I agree the usage as a function parameter is misleading though. We can probably switch to pytest.mark.usefixtures.
There was a problem hiding this comment.
We can probably switch to pytest.mark.usefixtures.
... and rename the fixture to « async_environment » or something? It’s true that the fixture doesn’t even return a backend class — it’s always « auto ». Hmm. Which means we might then get away with a custom mark, eg pytest.mark.is_async?
There was a problem hiding this comment.
Yeah, I only suggested it since it is supposed to be auto-detected now, and they could be parameterized like https://github.com/encode/httpx/pull/615/files#diff-21bb0534f2645b17f8572db206999d00R165-R171
Which I now see is done here: https://github.com/encode/httpx/pull/615/files#diff-484462fced51d1a06b1d93b4a44dd535R52-R64 so, well done! Sorry I missed that before.
It is a little confusing as a function param, so I would agree with renaming it "async_backend" and then using it as @pytest.mark.usefixtures("async_backend") since all it's doing is adding the mark for asyncio/trio to do their thing.
Following up comments from #614, this PR updates the tests so that:
"auto","asyncio","trio") to all pieces of public API."auto"option is put under test as well.Fixes a bunch of
NotImplementedErrors in theconcurrencytest utils as well.Tests that use the
backendare now twice as many (because thebackendfixture now has two more params - auto-in-asyncio and auto-in-trio). I figured the test suite was still fast enough that running all these tests for each situation was acceptable, rather than e.g. unit-testing that passing"asyncio"looks upAsyncioBackend. Now that I wrote about it I'm less sure this wouldn't be preferable.