-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Avoid runtime dependency on httpx unless testing is used #1826
Comments
Also love to see httpx removed as a requirement, especially if it's only used in testing. |
The main problem is there is sort of a lack of decent http clients that can reach inside an ASGI compatible application and execute it without standing up the server. That being said, yes, I agree that it is annoying. I am in favor of doing something like this especially so that production builds can be as lean as possible. I think this conversation does not stop with Seeing as we already have one method for removing some dependencies at install time ( The alternative would be to have various requirements relegated to extras:
To achieve this, we would probably need to add a constructor to |
Agreed, httpx looks like the most feasible choice.
Probably rather add functions to the class when the sanic module is imported. But wouldn't simple
I'm not a big fan of |
During the Steering-Council meeting yesterday, we concluded a good idea would be to split out the Then |
Closing in favor of #1850. See: https://github.com/huge-success/sanic-test |
@ashleysommer I pushed the repo before seeing your message. I like |
Conversation continued: https://community.sanicframework.org/t/sanic-testing-and-dependency-on-httpx/556 |
Sanic only depends on httpx for testing but that actually becomes a hard dependency because
sanic/__init__.py
importssanic.app
which importssanic.testing
that then importshttpx
. This is a problem because HTTPX frequently makes incompatible API changes and packages other than Sanic also depend on specific versions of it being installed.On Sanic master branch one cannot even
import sanic
if there is httpx<0.10 or httpx>=0.12 installed, in contrast with Sanic 19.12LTS where one must have httpx<0.10.Code could be restructured so that sanic.testing is only imported when needed. Possibly this means importing it inside
app.test_client
andapp.asgi_client
functions.A related question is whether testing should be moved to a separate package or to
pytest-sanic
, to avoid installation ofhttpx
by the main package.pip install
won't refuse installs when there are conflicting requirements but wrong versions may end up installed.Another alternative would be to use some other HTTP client in testing, one that has a more stable API and ideally one that would be fully asynchronous (encode/httpx#877).
Or if all of that seems too problematic, we could just do nothing and keep things the way they are, and try to keep up with httpx development. Care to share your thoughts?
The text was updated successfully, but these errors were encountered: