Skip to content
Myr

#1066 make BaseClient's timeout accessible using getters and setters (#1135)

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

authored by cdeler · committed by GitHub · parent 0e73be8 · Browse files · 2 files+23 added−2 removed
This commit

State

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

Diff stats

2 files+23 added−2 removed

  • tests:+14 added−1 removed
  • other:+9 added−1 removed

2 files+23 added−2 removed

modified:httpx/_client.py+9 added-1 removed
73 unmodified lines
74 self.auth = auth75 self._params = QueryParams(params)76 self._headers = Headers(headers)77 self._cookies = Cookies(cookies)78 self.timeout = Timeout(timeout)78 self._timeout = Timeout(timeout)79 self.max_redirects = max_redirects80 self._trust_env = trust_env81 self._netrc = NetRCInfo()82
26 unmodified lines
109 proxy = Proxy(url=proxies) if isinstance(proxies, (str, URL)) else proxies110 return {"all": proxy}111112 @property113 def timeout(self) -> Timeout:114 return self._timeout115116 @timeout.setter117 def timeout(self, timeout: TimeoutTypes) -> None:118 self._timeout = Timeout(timeout)119120 @property121 def base_url(self) -> URL:122 """123 Base URL to use when sending requests with relative URLs.124 """
1403 unmodified lines
modified:tests/client/test_properties.py+14 added-1 removed
1from httpx import URL, AsyncClient, Cookies, Headers1from httpx import URL, AsyncClient, Cookies, Headers, Timeout234def test_client_base_url():5 client = AsyncClient()
29 unmodified lines
35 assert isinstance(client.cookies, Cookies)36 mycookies = list(client.cookies.jar)37 assert len(mycookies) == 138 assert mycookies[0].name == "a" and mycookies[0].value == "b"394041def test_client_timeout():42 expected_timeout = 12.043 client = AsyncClient()4445 client.timeout = expected_timeout # type: ignore4647 assert isinstance(client.timeout, Timeout)48 assert client.timeout.connect == expected_timeout49 assert client.timeout.read == expected_timeout50 assert client.timeout.write == expected_timeout51 assert client.timeout.pool == expected_timeout