Originally opened by @florimondmanca on 2019-08-22 22:58:50 in encode/httpx
Now that almost all of HTTPX internals are relying on the concurrency backend, and before tackling the Trio backend (#120), it would be good to parametrize all tests with a backend fixture.
For now, it would only point to AsyncioBackend, but we're going to need it for TrioBackend anyway — the main goal is to reduce clutter when the trio backend lands a PR.
Once the backend fixture is defined, any test that uses AsyncClient, HTTPConnection or ConnectionPool can basically be parametrized with it, e.g.:
# conftest.py
`@pytest`.fixture(params=[pytest.param(AsyncioBackend, marks=pytest.mark.asyncio)])
def backend(request):
backend_cls = request.param
return backend_cls()
# test_async_client.py
async def test_get(backend):
async with AsyncClient(backend=backend) as client:
I'll tackle this look soon, but if anyone has thoughts on this approach let me know. :-)
Now that almost all of HTTPX internals are relying on the concurrency backend, and before tackling the Trio backend (#120), it would be good to parametrize all tests with a
backendfixture.For now, it would only point to
AsyncioBackend, but we're going to need it forTrioBackendanyway — the main goal is to reduce clutter when the trio backend lands a PR.Once the
backendfixture is defined, any test that usesAsyncClient,HTTPConnectionorConnectionPoolcan basically be parametrized with it, e.g.:I'll tackle this look soon, but if anyone has thoughts on this approach let me know. :-)