Is there a good way to use multiple TestClient
instances?
#2956
Unanswered
tomkcook
asked this question in
Potential Issue
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a web application with several user roles. I've been testing it using
httpx
, with a different pytest fixture for each role:I'm now trying to change my tests to use the starlette
TestClient
so that I can generate full test coverage statistics. Changing the code above to useTestClient
naively causes problems:If I use these in the wrong order, I get exceptions of this variety:
It doesn't seem to make any difference if the fixtures are
async
or not.Is there a good way of making this work? I can get by with a single client, of course, and manually specify the authorization header for every request. It'd be a lot more convenient if I didn't have to, though.
Beta Was this translation helpful? Give feedback.
All reactions