Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backend test parametrization #271

Closed
florimondmanca opened this issue Aug 22, 2019 · 0 comments · Fixed by #273
Closed

Backend test parametrization #271

florimondmanca opened this issue Aug 22, 2019 · 0 comments · Fixed by #273

Comments

@florimondmanca
Copy link
Member

florimondmanca commented Aug 22, 2019

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. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant