Skip to content
Myr

Exception hierarchy (#1095)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* Exception heirachy * Exception heirarchy * Formatting tweaks * Update httpx/_exceptions.py Co-authored-by: Florimond Manca <florimond.manca@gmail.com> * Update httpx/_exceptions.py Co-authored-by: Florimond Manca <florimond.manca@gmail.com> * Update httpx/_exceptions.py Co-authored-by: Florimond Manca <florimond.manca@gmail.com> * Update httpx/_exceptions.py Co-authored-by: Florimond Manca <florimond.manca@gmail.com>

authored by Tom Christie · committed by GitHub · parent 2ba9c1e · Browse files · 11 files+218 added−108 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Co-authored-by: Florimond Manca <florimond.manca@gmail.com>

Diff stats

11 files+218 added−108 removed

  • tests:+14 added−9 removed
  • other:+204 added−99 removed

11 files+218 added−108 removed

modified:httpx/__init__.py+4 added-2 removed
17 unmodified lines
18 ProtocolError,19 ProxyError,20 ReadError,21 ReadTimeout,22 RedirectError,22 RequestBodyUnavailable,23 RequestError,24 RequestNotRead,25 ResponseClosed,26 ResponseNotRead,27 StreamConsumed,28 StreamError,29 TimeoutException,30 TooManyRedirects,31 TransportError,32 WriteError,33 WriteTimeout,34)35from ._models import URL, Cookies, Headers, QueryParams, Request, Response
40 unmodified lines
76 "PoolTimeout",77 "ProtocolError",78 "ReadError",79 "ReadTimeout",79 "RedirectError",80 "RequestError",81 "RequestBodyUnavailable",82 "ResponseClosed",83 "ResponseNotRead",84 "RequestNotRead",
2 unmodified lines
87 "StreamError",88 "ProxyError",89 "TimeoutException",90 "TooManyRedirects",91 "TransportError",92 "WriteError",93 "WriteTimeout",94 "URL",95 "URLLib3Transport",
9 unmodified lines
modified:httpx/_auth.py+16 added-8 removed
114 unmodified lines
115 # If the response is not a 401 WWW-Authenticate, then we don't116 # need to build an authenticated request.117 return118119 header = response.headers["www-authenticate"]120 challenge = self._parse_challenge(header)119 challenge = self._parse_challenge(request, response)120 request.headers["Authorization"] = self._build_auth_header(request, challenge)121 yield request122124 def _parse_challenge(self, header: str) -> "_DigestAuthChallenge":123 def _parse_challenge(124 self, request: Request, response: Response125 ) -> "_DigestAuthChallenge":126 """127 Returns a challenge from a Digest WWW-Authenticate header.128 These take the form of:129 `Digest realm="realm@host.com",qop="auth,auth-int",nonce="abc",opaque="xyz"`130 """131 header = response.headers["www-authenticate"]132133 scheme, _, fields = header.partition(" ")134 if scheme.lower() != "digest":132 raise ProtocolError("Header does not start with 'Digest'")135 message = "Header does not start with 'Digest'"136 raise ProtocolError(message, request=request)137138 header_dict: typing.Dict[str, str] = {}139 for field in parse_http_list(fields):140 key, value = field.strip().split("=", 1)
8 unmodified lines
149 return _DigestAuthChallenge(150 realm=realm, nonce=nonce, qop=qop, opaque=opaque, algorithm=algorithm151 )152 except KeyError as exc:149 raise ProtocolError("Malformed Digest WWW-Authenticate header") from exc153 message = "Malformed Digest WWW-Authenticate header"154 raise ProtocolError(message, request=request) from exc155156 def _build_auth_header(157 self, request: Request, challenge: "_DigestAuthChallenge"158 ) -> str:
16 unmodified lines
175 HA1 = digest(A1)176 if challenge.algorithm.lower().endswith("-sess"):177 HA1 = digest(b":".join((HA1, challenge.nonce, cnonce)))178174 qop = self._resolve_qop(challenge.qop)179 qop = self._resolve_qop(challenge.qop, request=request)180 if qop is None:181 digest_data = [HA1, challenge.nonce, HA2]182 else:183 digest_data = [challenge.nonce, nc_value, cnonce, qop, HA2]
41 unmodified lines
225 header_value += template.format(field, to_str(value))226227 return header_value228224 def _resolve_qop(self, qop: typing.Optional[bytes]) -> typing.Optional[bytes]:229 def _resolve_qop(230 self, qop: typing.Optional[bytes], request: Request231 ) -> typing.Optional[bytes]:232 if qop is None:233 return None234 qops = re.split(b", ?", qop)235 if b"auth" in qops:
1 unmodified line
237238 if qops == [b"auth-int"]:239 raise NotImplementedError("Digest auth-int support is not yet implemented")240234 raise ProtocolError(f'Unexpected qop value "{qop!r}" in digest auth')241 message = f'Unexpected qop value "{qop!r}" in digest auth'242 raise ProtocolError(message, request=request)243244245class _DigestAuthChallenge:246 def __init__(
12 unmodified lines
modified:httpx/_client.py+12 added-8 removed
322 unmodified lines
323 url = URL(location)324325 # Check that we can handle the scheme326 if url.scheme and url.scheme not in ("http", "https"):327 raise InvalidURL(f'Scheme "{url.scheme}" not supported.')327 message = f'Scheme "{url.scheme}" not supported.'328 raise InvalidURL(message, request=request)329330 # Handle malformed 'Location' headers that are "absolute" form, have no host.331 # See: https://github.com/encode/httpx/issues/771332 if url.scheme and not url.host:
204 unmodified lines
537 keepalive_expiry=KEEPALIVE_EXPIRY,538 http2=http2,539 )540540 def _transport_for_url(self, url: URL) -> httpcore.SyncHTTPTransport:541 def _transport_for_url(self, request: Request) -> httpcore.SyncHTTPTransport:542 """543 Returns the transport instance that should be used for a given URL.544 This will either be the standard connection pool, or a proxy.545 """546 url = request.url545 enforce_http_url(url)547 enforce_http_url(request)548549 if self._proxies and not should_not_be_proxied(url):550 for matcher, transport in self._proxies.items():551 if matcher.matches(url):
39 unmodified lines
591 allow_redirects: bool = True,592 timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET,593 ) -> Response:594 if request.url.scheme not in ("http", "https"):593 raise InvalidURL('URL scheme must be "http" or "https".')595 message = 'URL scheme must be "http" or "https".'596 raise InvalidURL(message, request=request)597598 timeout = self.timeout if isinstance(timeout, UnsetType) else Timeout(timeout)599600 auth = self._build_auth(request, auth)
83 unmodified lines
684 def _send_single_request(self, request: Request, timeout: Timeout) -> Response:685 """686 Sends a single request, without handling any redirections.687 """685 transport = self._transport_for_url(request.url)688 transport = self._transport_for_url(request)689690 with map_exceptions(HTTPCORE_EXC_MAP, request=request):691 (692 http_version,
368 unmodified lines
1061 keepalive_expiry=KEEPALIVE_EXPIRY,1062 http2=http2,1063 )10641062 def _transport_for_url(self, url: URL) -> httpcore.AsyncHTTPTransport:1065 def _transport_for_url(self, request: Request) -> httpcore.AsyncHTTPTransport:1066 """1067 Returns the transport instance that should be used for a given URL.1068 This will either be the standard connection pool, or a proxy.1069 """1070 url = request.url1067 enforce_http_url(url)1071 enforce_http_url(request)10721073 if self._proxies and not should_not_be_proxied(url):1074 for matcher, transport in self._proxies.items():1075 if matcher.matches(url):
131 unmodified lines
1207 ) -> Response:1208 """1209 Sends a single request, without handling any redirections.1210 """1207 transport = self._transport_for_url(request.url)1211 transport = self._transport_for_url(request)12121213 with map_exceptions(HTTPCORE_EXC_MAP, request=request):1214 (1215 http_version,
276 unmodified lines
modified:httpx/_decoders.py+26 added-15 removed
14 unmodified lines
15 import brotli16except ImportError: # pragma: nocover17 brotli = None1819if typing.TYPE_CHECKING: # pragma: no cover20 from ._models import Request212223class Decoder:24 def __init__(self, request: "Request") -> None:25 self.request = request2627 def decode(self, data: bytes) -> bytes:28 raise NotImplementedError() # pragma: nocover2930 def flush(self) -> bytes:
18 unmodified lines
4950 See: https://stackoverflow.com/questions/183869951 """5247 def __init__(self) -> None:53 def __init__(self, request: "Request") -> None:54 self.request = request55 self.first_attempt = True56 self.decompressor = zlib.decompressobj()5758 def decode(self, data: bytes) -> bytes:
4 unmodified lines
63 except zlib.error as exc:64 if was_first_attempt:65 self.decompressor = zlib.decompressobj(-zlib.MAX_WBITS)66 return self.decode(data)60 raise DecodingError from exc67 raise DecodingError(message=str(exc), request=self.request)6869 def flush(self) -> bytes:70 try:71 return self.decompressor.flush()72 except zlib.error as exc: # pragma: nocover66 raise DecodingError from exc73 raise DecodingError(message=str(exc), request=self.request)747576class GZipDecoder(Decoder):77 """
1 unmodified line
7980 See: https://stackoverflow.com/questions/183869981 """8276 def __init__(self) -> None:83 def __init__(self, request: "Request") -> None:84 self.request = request85 self.decompressor = zlib.decompressobj(zlib.MAX_WBITS | 16)8687 def decode(self, data: bytes) -> bytes:88 try:89 return self.decompressor.decompress(data)90 except zlib.error as exc:83 raise DecodingError from exc91 raise DecodingError(message=str(exc), request=self.request)9293 def flush(self) -> bytes:94 try:95 return self.decompressor.flush()96 except zlib.error as exc: # pragma: nocover89 raise DecodingError from exc97 raise DecodingError(message=str(exc), request=self.request)9899100class BrotliDecoder(Decoder):101 """
4 unmodified lines
106 Supports both 'brotlipy' and 'Brotli' packages since they share an import107 name. The top branches are for 'brotlipy' and bottom branches for 'Brotli'108 """109102 def __init__(self) -> None:110 def __init__(self, request: "Request") -> None:111 assert (112 brotli is not None113 ), "The 'brotlipy' or 'brotli' library must be installed to use 'BrotliDecoder'"114 self.request = request115 self.decompressor = brotli.Decompressor()116 self.seen_data = False117 if hasattr(self.decompressor, "decompress"):118 self._decompress = self.decompressor.decompress
6 unmodified lines
125 self.seen_data = True126 try:127 return self._decompress(data)128 except brotli.error as exc:120 raise DecodingError from exc129 raise DecodingError(message=str(exc), request=self.request)130131 def flush(self) -> bytes:132 if not self.seen_data:133 return b""
1 unmodified line
135 if hasattr(self.decompressor, "finish"):136 self.decompressor.finish()137 return b""138 except brotli.error as exc: # pragma: nocover130 raise DecodingError from exc139 raise DecodingError(message=str(exc), request=self.request)140141142class MultiDecoder(Decoder):143 """
24 unmodified lines
168 """169 Handles incrementally decoding bytes into text170 """171163 def __init__(self, encoding: typing.Optional[str] = None):172 def __init__(self, request: "Request", encoding: typing.Optional[str] = None):173 self.request = request174 self.decoder: typing.Optional[codecs.IncrementalDecoder] = (175 None if encoding is None else codecs.getincrementaldecoder(encoding)()176 )177 self.detector = chardet.universaldetector.UniversalDetector()
25 unmodified lines
203 text = self.decoder.decode(bytes(self.buffer), False)204 self.buffer = None205206 return text197 except UnicodeDecodeError: # pragma: nocover198 raise DecodingError() from None207 except UnicodeDecodeError as exc: # pragma: nocover208 raise DecodingError(message=str(exc), request=self.request)209210 def flush(self) -> str:211 try:212 if self.decoder is None:
3 unmodified lines
216 return ""217 return bytes(self.buffer).decode(self._detector_result())218219 return self.decoder.decode(b"", True)210 except UnicodeDecodeError: # pragma: nocover211 raise DecodingError() from None220 except UnicodeDecodeError as exc: # pragma: nocover221 raise DecodingError(message=str(exc), request=self.request)222223 def _detector_result(self) -> str:224 self.detector.close()225 result = self.detector.result["encoding"]226 if not result: # pragma: nocover217 raise DecodingError("Unable to determine encoding of content")227 message = "Unable to determine encoding of content"228 raise DecodingError(message, request=self.request)229230 return result231232
77 unmodified lines
modified:httpx/_exceptions.py+120 added-52 removed
1"""2Our exception hierarchy:34* RequestError5 + TransportError6 - TimeoutException7 · ConnectTimeout8 · ReadTimeout9 · WriteTimeout10 · PoolTimeout11 - NetworkError12 · ConnectError13 · ReadError14 · WriteError15 · CloseError16 - ProxyError17 - ProtocolError18 + DecodingError19 + TooManyRedirects20 + RequestBodyUnavailable21 + InvalidURL22* HTTPStatusError23* NotRedirectResponse24* CookieConflict25* StreamError26 + StreamConsumed27 + ResponseNotRead28 + RequestNotRead29 + ResponseClosed30"""31import contextlib32import typing3334import httpcore
1 unmodified line
36if typing.TYPE_CHECKING:37 from ._models import Request, Response # pragma: nocover383910class HTTPError(Exception):40class RequestError(Exception):41 """12 Base class for all HTTPX exceptions.42 Base class for all exceptions that may occur when issuing a `.request()`.43 """4415 def __init__(16 self, *args: typing.Any, request: "Request" = None, response: "Response" = None17 ) -> None:18 super().__init__(*args)19 self._request = request or (response.request if response is not None else None)20 self.response = response45 def __init__(self, message: str, *, request: "Request") -> None:46 super().__init__(message)47 self.request = request4822 @property23 def request(self) -> "Request":24 # NOTE: this property exists so that a `Request` is exposed to type25 # checkers, instead of `Optional[Request]`.26 assert self._request is not None # Populated by the client.27 return self._request4950class TransportError(RequestError):51 """52 Base class for all exceptions that are mapped from the httpcore API.53 """545556# Timeout exceptions...575833class TimeoutException(HTTPError):59class TimeoutException(TransportError):60 """61 The base class for timeout errors.6263 An operation has timed out.
26 unmodified lines
9091# Core networking exceptions...929368class NetworkError(HTTPError):94class NetworkError(TransportError):95 """96 The base class for network-related errors.9798 An error occurred while interacting with the network.
26 unmodified lines
125126# Other transport exceptions...127128103class ProxyError(HTTPError):129class ProxyError(TransportError):130 """131 An error occurred while proxying a request.132 """133134109class ProtocolError(HTTPError):135class ProtocolError(TransportError):136 """137 A protocol was violated by the server.138 """139140115# HTTP exceptions...141# Other request exceptions...142143118class DecodingError(HTTPError):144class DecodingError(RequestError):145 """146 Decoding of the response failed.147 """148149124class HTTPStatusError(HTTPError):150class TooManyRedirects(RequestError):151 """126 Response sent an error HTTP status.152 Too many redirects.153 """154129 def __init__(self, *args: typing.Any, response: "Response") -> None:130 super().__init__(*args)131 self._request = response.request132 self.response = response155156class RequestBodyUnavailable(RequestError):157 """158 Had to send the request again, but the request body was streaming, and is159 no longer available.160 """161135# Redirect exceptions...162137138class RedirectError(HTTPError):163class InvalidURL(RequestError):164 """140 Base class for HTTP redirect errors.165 URL was missing a hostname, or was not one of HTTP/HTTPS.166 """167168144class TooManyRedirects(RedirectError):169# Client errors170171172class HTTPStatusError(Exception):173 """146 Too many redirects.174 Response sent an error HTTP status.175176 May be raised when calling `response.raise_for_status()`177 """178179 def __init__(180 self, message: str, *, request: "Request", response: "Response"181 ) -> None:182 super().__init__(message)183 self.request = request184 self.response = response185186150class NotRedirectResponse(RedirectError):187class NotRedirectResponse(Exception):188 """189 Response was not a redirect response.190191 May be raised if `response.next()` is called without first192 properly checking `response.is_redirect`.193 """194195 def __init__(self, message: str) -> None:196 super().__init__(message)197198199class CookieConflict(Exception):200 """201 Attempted to lookup a cookie by name, but multiple cookies existed.202203 Can occur when calling `response.cookies.get(...)`.204 """205206 def __init__(self, message: str) -> None:207 super().__init__(message)208209210# Stream exceptions...211212# These may occur as the result of a programming error, by accessing213# the request/response stream in an invalid manner.214215159class StreamError(HTTPError):216class StreamError(Exception):217 """218 The base class for stream exceptions.219220 The developer made an error in accessing the request stream in221 an invalid way.222 """223224 def __init__(self, message: str) -> None:225 super().__init__(message)226168class RequestBodyUnavailable(StreamError):169 """170 Had to send the request again, but the request body was streaming, and is171 no longer available.172 """227174228class StreamConsumed(StreamError):229 """230 Attempted to read or stream response content, but the content has already231 been streamed.232 """233234 def __init__(self) -> None:235 message = (236 "Attempted to read or stream response content, but the content has "237 "already been streamed."238 )239 super().__init__(message)240241242class ResponseNotRead(StreamError):243 """244 Attempted to access response content, without having called `read()`245 after a streaming response.246 """247248 def __init__(self) -> None:249 message = (250 "Attempted to access response content, without having called `read()` "251 "after a streaming response."252 )253 super().__init__(message)254255256class RequestNotRead(StreamError):257 """258 Attempted to access request content, without having called `read()`.259 """260261 def __init__(self) -> None:262 message = "Attempted to access request content, without having called `read()`."263 super().__init__(message)264265266class ResponseClosed(StreamError):267 """268 Attempted to read or stream response content, but the request has been269 closed.270 """271272 def __init__(self) -> None:273 message = (274 "Attempted to read or stream response content, but the request has "275 "been closed."276 )277 super().__init__(message)278202# Other cases...279280# We're continuing to expose this earlier naming at the moment.281# It is due to be deprecated. Don't use it.282HTTPError = RequestError283205class InvalidURL(HTTPError):206 """207 URL was missing a hostname, or was not one of HTTP/HTTPS.208 """284210211class CookieConflict(HTTPError):212 """213 Attempted to lookup a cookie by name, but multiple cookies existed.214 """215216285@contextlib.contextmanager286def map_exceptions(287 mapping: typing.Mapping[typing.Type[Exception], typing.Type[Exception]],288 **kwargs: typing.Any,
36 unmodified lines
modified:httpx/_models.py+16 added-9 removed
796 unmodified lines
797 for value in values:798 value = value.strip().lower()799 try:800 decoder_cls = SUPPORTED_DECODERS[value]801 decoders.append(decoder_cls())801 decoders.append(decoder_cls(request=self.request))802 except KeyError:803 continue804805 if len(decoders) == 1:806 self._decoder = decoders[0]807 elif len(decoders) > 1:808 self._decoder = MultiDecoder(decoders)808 self._decoder = MultiDecoder(children=decoders)809 else:810 self._decoder = IdentityDecoder()810 self._decoder = IdentityDecoder(request=self.request)811812 return self._decoder813814 @property
14 unmodified lines
829 )830831 if codes.is_client_error(self.status_code):832 message = message.format(self, error_type="Client Error")833 raise HTTPStatusError(message, response=self)833 raise HTTPStatusError(message, request=self.request, response=self)834 elif codes.is_server_error(self.status_code):835 message = message.format(self, error_type="Server Error")836 raise HTTPStatusError(message, response=self)836 raise HTTPStatusError(message, request=self.request, response=self)837838 def json(self, **kwargs: typing.Any) -> typing.Any:839 if self.charset_encoding is None and self.content and len(self.content) > 3:840 encoding = guess_json_utf(self.content)
53 unmodified lines
894 A str-iterator over the decoded response content895 that handles both gzip, deflate, etc but also detects the content's896 string encoding.897 """898 decoder = TextDecoder(encoding=self.charset_encoding)898 decoder = TextDecoder(request=self.request, encoding=self.charset_encoding)899 for chunk in self.iter_bytes():900 yield decoder.decode(chunk)901 yield decoder.flush()902
23 unmodified lines
926 """927 Get the next response from a redirect response.928 """929 if not self.is_redirect:930 message = (931 "Called .next(), but the response was not a redirect. "932 "Calling code should check `response.is_redirect` first."933 )930 raise NotRedirectResponse()934 raise NotRedirectResponse(message)935 assert self.call_next is not None936 return self.call_next()937938 def close(self) -> None:
32 unmodified lines
971 A str-iterator over the decoded response content972 that handles both gzip, deflate, etc but also detects the content's973 string encoding.974 """971 decoder = TextDecoder(encoding=self.charset_encoding)975 decoder = TextDecoder(request=self.request, encoding=self.charset_encoding)976 async for chunk in self.aiter_bytes():977 yield decoder.decode(chunk)978 yield decoder.flush()979
23 unmodified lines
1003 """1004 Get the next response from a redirect response.1005 """1006 if not self.is_redirect:1003 raise NotRedirectResponse()1007 raise NotRedirectResponse(1008 "Called .anext(), but the response was not a redirect. "1009 "Calling code should check `response.is_redirect` first."1010 )1011 assert self.call_next is not None1012 return await self.call_next()10131014 async def aclose(self) -> None:
183 unmodified lines
modified:httpx/_utils.py+10 added-5 removed
16 unmodified lines
17from ._exceptions import InvalidURL18from ._types import PrimitiveData1920if typing.TYPE_CHECKING: # pragma: no cover21 from ._models import URL21 from ._models import URL, Request222324_HTML5_FORM_ENCODING_REPLACEMENTS = {'"': "%22", "\\": "\\\\"}25_HTML5_FORM_ENCODING_REPLACEMENTS.update(
238 unmodified lines
264265 return typing.cast(Logger, logger)266267268def enforce_http_url(url: "URL") -> None:268def enforce_http_url(request: "Request") -> None:269 """270 Raise an appropriate InvalidURL for any non-HTTP URLs.271 """272 url = request.url273274 if not url.scheme:273 raise InvalidURL("No scheme included in URL.")275 message = "No scheme included in URL."276 raise InvalidURL(message, request=request)277 if not url.host:275 raise InvalidURL("No host included in URL.")278 message = "No host included in URL."279 raise InvalidURL(message, request=request)280 if url.scheme not in ("http", "https"):277 raise InvalidURL('URL scheme must be "http" or "https".')281 message = 'URL scheme must be "http" or "https".'282 raise InvalidURL(message, request=request)283284285def port_or_default(url: "URL") -> typing.Optional[int]:286 if url.port is not None:
236 unmodified lines
modified:tests/client/test_proxies.py+4 added-2 removed
92 unmodified lines
93 ],94)95def test_transport_for_request(url, proxies, expected):96 client = httpx.AsyncClient(proxies=proxies)97 request = httpx.Request(method="GET", url=url)97 transport = client._transport_for_url(httpx.URL(url))98 transport = client._transport_for_url(request)99100 if expected is None:101 assert transport is client._transport102 else:
38 unmodified lines
141 for name, value in env.items():142 monkeypatch.setenv(name, value)143144 client = client_class()145 request = httpx.Request(method="GET", url=url)144 transport = client._transport_for_url(httpx.URL(url))146 transport = client._transport_for_url(request)147148 if expected is None:149 assert transport == client._transport150 else:
1 unmodified line
modified:tests/test_asgi.py+2 added-2 removed
64 unmodified lines
656667@pytest.mark.usefixtures("async_environment")68async def test_asgi_http_error():69 client = httpx.AsyncClient(app=partial(raise_exc, exc=httpx.HTTPError))70 with pytest.raises(httpx.HTTPError):69 client = httpx.AsyncClient(app=partial(raise_exc, exc=RuntimeError))70 with pytest.raises(RuntimeError):71 await client.get("http://www.example.org/")727374@pytest.mark.usefixtures("async_environment")
37 unmodified lines
modified:tests/test_decoders.py+6 added-3 removed
133 unmodified lines
134@pytest.mark.parametrize(135 "decoder", (BrotliDecoder, DeflateDecoder, GZipDecoder, IdentityDecoder)136)137def test_decoders_empty_cases(decoder):138 request = httpx.Request(method="GET", url="https://www.example.com")138 instance = decoder()139 instance = decoder(request)140 assert instance.decode(b"") == b""141 assert instance.flush() == b""142143
62 unmodified lines
206 assert "".join(response.text) == "トラベル"207208209def test_text_decoder_empty_cases():210 request = httpx.Request(method="GET", url="https://www.example.com")211209 decoder = TextDecoder()212 decoder = TextDecoder(request=request)213 assert decoder.flush() == ""214212 decoder = TextDecoder()215 decoder = TextDecoder(request=request)216 assert decoder.decode(b"") == ""217 assert decoder.flush() == ""218219
75 unmodified lines
modified:tests/test_wsgi.py+2 added-2 removed
95 unmodified lines
96 client.get("http://www.example.org/")979899def test_wsgi_http_error():100 client = httpx.Client(app=partial(raise_exc, exc=httpx.HTTPError))101 with pytest.raises(httpx.HTTPError):100 client = httpx.Client(app=partial(raise_exc, exc=RuntimeError))101 with pytest.raises(RuntimeError):102 client.get("http://www.example.org/")103104105def test_wsgi_generator():
13 unmodified lines