Sometimes, it would be nice to initialize multiple Testclient
s, but only do the blocking portal magic once. The request routing magic lives in TestClient(Transport)
so simply copying the base_url
to a httpx.Client
won't work (found out by trying).
An example where this could be needed is when testing the API from the perspective of 2 different users. Using just one client might not be feasible due to cookies that server could set (should be different for the two users) and in general it would be nice to have the two separated.
client = TestClient(app=app)
client.get(..., auth=user1_auth) # requires also...
client.get(..., auth=user2_auth) # ...this repetition
Maybe something like:
with create_portal(app) as portal:
user1 = TestClient(portal=portal, auth=...)
user2 = TestClient(portal=portal, auth=...)
user1.get(...)
user2.get(...)
No response
No response
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too