Skip to content

Commit

Permalink
Add clear error message when httpx is not installed (#2177)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kludex committed Jun 6, 2023
1 parent d155d3b commit e981768
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion starlette/testclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,21 @@

import anyio
import anyio.from_thread
import httpx
from anyio.streams.stapled import StapledObjectStream

from starlette._utils import is_async_callable
from starlette.types import ASGIApp, Message, Receive, Scope, Send
from starlette.websockets import WebSocketDisconnect

try:
import httpx
except ModuleNotFoundError: # pragma: no cover
raise RuntimeError(
"The starlette.testclient module requires the httpx package to be installed.\n"
"You can install this with:\n"
" $ pip install httpx\n"
)

if sys.version_info >= (3, 8): # pragma: no cover
from typing import TypedDict
else: # pragma: no cover
Expand Down

0 comments on commit e981768

Please sign in to comment.