httpx giving UnsupportedProtocl error while running tests #1643
Unanswered
onlinejudge95
asked this question in
Potential Issue
Replies: 1 comment 1 reply
-
|
You're probably not setting We should probably include more information in that exception to make it clear what the full requested URL was, and make it more obvious that it was missing the "https://" or "http://" portion. |
Beta Was this translation helpful? Give feedback.
1 reply
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.
Uh oh!
There was an error while loading. Please reload this page.
-
While implementing a unit test for a FastAPI server particularly in a GET route in which I am using
httpxto send a get request(with some query params) to another service, I am receiving the following error@contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: nocover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.UnsupportedProtocol: Unsupported URL protocol '' ../../../.pyenv/versions/3.9.4/envs/api-gateway/lib/python3.9/site-packages/httpx/_transports/default.py:78: UnsupportedProtocol ... ========================================================================================= short test summary info ========================================================================================== FAILED tests/email/test_routes.py::test_fetch_email_fails_invalid_params[http://localhost:8000/api/email/-request_body0-400] - httpx.UnsupportedProtocol: Unsupported URL protocol ''The test in question is
For full traceback please refer to the following GitHub action run
My entire codebase can be found here
Link to the failing test file
Link to System under test
Beta Was this translation helpful? Give feedback.
All reactions