Replace httpx.URL for str in tests (#1237)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Eduardo Enriquez · committed by GitHub · parent 9200cb0 · Browse files · 4 files·+26 added−32 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: Eduardo Enriquez (eduzen) <eduardo.enriquez@freshbooks.com>
Diff stats
4 files+26 added−32 removed
- tests:+26 added−32 removed
Provenance
- Commit
aad8209- Tree
43b8ed0- Author
Eduardo Enriquez <eduardo.a.enriquez@gmail.com>- Committer
GitHub <noreply@github.com>- Parent
9200cb0
4 files changed+26 added−32 removed
modified:tests/client/test_client.py+4 added-4 removed
176 unmodified lines177 178 def test_merge_absolute_url():179 client = httpx.Client(base_url="https://www.example.com/")180 request = client.build_request("GET", "http://www.example.com/")181- assert request.url == httpx.URL("http://www.example.com/")181+ assert request.url == "http://www.example.com/"182 with pytest.warns(DeprecationWarning):183 assert not request.url.is_ssl184 185 186 def test_merge_relative_url():187 client = httpx.Client(base_url="https://www.example.com/")188 request = client.build_request("GET", "/testing/123")189- assert request.url == httpx.URL("https://www.example.com/testing/123")189+ assert request.url == "https://www.example.com/testing/123"190 191 192 def test_merge_relative_url_with_path():193 client = httpx.Client(base_url="https://www.example.com/some/path")194 request = client.build_request("GET", "/testing/123")195- assert request.url == httpx.URL("https://www.example.com/some/path/testing/123")195+ assert request.url == "https://www.example.com/some/path/testing/123"196 197 198 def test_merge_relative_url_with_dotted_path():199 client = httpx.Client(base_url="https://www.example.com/some/path")200 request = client.build_request("GET", "../testing/123")201- assert request.url == httpx.URL("https://www.example.com/some/testing/123")201+ assert request.url == "https://www.example.com/some/testing/123"202 203 204 def test_pool_limits_deprecated():205 limits = httpx.Limits()44 unmodified linesmodified:tests/client/test_properties.py+3 added-3 removed
3 unmodified lines4 def test_client_base_url():5 client = httpx.Client()6 client.base_url = "https://www.example.org/" # type: ignore7 assert isinstance(client.base_url, httpx.URL)8- assert client.base_url == httpx.URL("https://www.example.org/")8+ assert client.base_url == "https://www.example.org/"9 10 11 def test_client_base_url_without_trailing_slash():12 client = httpx.Client()13 client.base_url = "https://www.example.org/path" # type: ignore14 assert isinstance(client.base_url, httpx.URL)15- assert client.base_url == httpx.URL("https://www.example.org/path/")15+ assert client.base_url == "https://www.example.org/path/"16 17 18 def test_client_base_url_with_trailing_slash():19 client = httpx.Client()20 client.base_url = "https://www.example.org/path/" # type: ignore21 assert isinstance(client.base_url, httpx.URL)22- assert client.base_url == httpx.URL("https://www.example.org/path/")22+ assert client.base_url == "https://www.example.org/path/"23 24 25 def test_client_headers():26 client = httpx.Client()25 unmodified linesmodified:tests/client/test_queryparams.py+1 added-3 removed
44 unmodified lines45 client = httpx.Client(transport=MockTransport(), params=client_queryparams)46 response = client.get(url, params=request_queryparams)47 48 assert response.status_code == 20049- assert response.url == httpx.URL(50- "http://example.org/echo_queryparams?first=str&second=dict"51- )49+ assert response.url == "http://example.org/echo_queryparams?first=str&second=dict"modified:tests/client/test_redirects.py+18 added-22 removed
184 unmodified lines185 def test_redirect_301():186 client = httpx.Client(transport=SyncMockTransport())187 response = client.post("https://example.org/redirect_301")188 assert response.status_code == httpx.codes.OK189- assert response.url == httpx.URL("https://example.org/")189+ assert response.url == "https://example.org/"190 assert len(response.history) == 1191 192 193 def test_redirect_302():194 client = httpx.Client(transport=SyncMockTransport())195 response = client.post("https://example.org/redirect_302")196 assert response.status_code == httpx.codes.OK197- assert response.url == httpx.URL("https://example.org/")197+ assert response.url == "https://example.org/"198 assert len(response.history) == 1199 200 201 def test_redirect_303():202 client = httpx.Client(transport=SyncMockTransport())203 response = client.get("https://example.org/redirect_303")204 assert response.status_code == httpx.codes.OK205- assert response.url == httpx.URL("https://example.org/")205+ assert response.url == "https://example.org/"206 assert len(response.history) == 1207 208 209 def test_disallow_redirects():210 client = httpx.Client(transport=SyncMockTransport())211 response = client.post("https://example.org/redirect_303", allow_redirects=False)212 assert response.status_code == httpx.codes.SEE_OTHER213- assert response.url == httpx.URL("https://example.org/redirect_303")213+ assert response.url == "https://example.org/redirect_303"214 assert response.is_redirect is True215 assert len(response.history) == 0216 217 response = response.next()218 assert response.status_code == httpx.codes.OK219- assert response.url == httpx.URL("https://example.org/")219+ assert response.url == "https://example.org/"220 assert response.is_redirect is False221 assert len(response.history) == 1222 223 3 unmodified lines227 """228 client = httpx.Client(transport=SyncMockTransport())229 response = client.head("https://example.org/redirect_302")230 assert response.status_code == httpx.codes.OK231- assert response.url == httpx.URL("https://example.org/")231+ assert response.url == "https://example.org/"232 assert response.request.method == "HEAD"233 assert len(response.history) == 1234 assert response.text == ""235 1 unmodified line237 def test_relative_redirect():238 client = httpx.Client(transport=SyncMockTransport())239 response = client.get("https://example.org/relative_redirect")240 assert response.status_code == httpx.codes.OK241- assert response.url == httpx.URL("https://example.org/")241+ assert response.url == "https://example.org/"242 assert len(response.history) == 1243 244 245 def test_malformed_redirect():246 # https://github.com/encode/httpx/issues/771247 client = httpx.Client(transport=SyncMockTransport())248 response = client.get("http://example.org/malformed_redirect")249 assert response.status_code == httpx.codes.OK250- assert response.url == httpx.URL("https://example.org:443/")250+ assert response.url == "https://example.org:443/"251 assert len(response.history) == 1252 253 254 def test_invalid_redirect():5 unmodified lines260 def test_no_scheme_redirect():261 client = httpx.Client(transport=SyncMockTransport())262 response = client.get("https://example.org/no_scheme_redirect")263 assert response.status_code == httpx.codes.OK264- assert response.url == httpx.URL("https://example.org/")264+ assert response.url == "https://example.org/"265 assert len(response.history) == 1266 267 268 def test_fragment_redirect():269 client = httpx.Client(transport=SyncMockTransport())270 response = client.get("https://example.org/relative_redirect#fragment")271 assert response.status_code == httpx.codes.OK272- assert response.url == httpx.URL("https://example.org/#fragment")272+ assert response.url == "https://example.org/#fragment"273 assert len(response.history) == 1274 275 276 def test_multiple_redirects():277 client = httpx.Client(transport=SyncMockTransport())278 response = client.get("https://example.org/multiple_redirects?count=20")279 assert response.status_code == httpx.codes.OK280- assert response.url == httpx.URL("https://example.org/multiple_redirects")280+ assert response.url == "https://example.org/multiple_redirects"281 assert len(response.history) == 20282- assert response.history[0].url == httpx.URL(283- "https://example.org/multiple_redirects?count=20"284- )285- assert response.history[1].url == httpx.URL(286- "https://example.org/multiple_redirects?count=19"287- )282+ assert response.history[0].url == "https://example.org/multiple_redirects?count=20"283+ assert response.history[1].url == "https://example.org/multiple_redirects?count=19"284 assert len(response.history[0].history) == 0285 assert len(response.history[1].history) == 1286 287 39 unmodified lines327 client = httpx.Client(transport=SyncMockTransport())328 url = "https://example.com/cross_domain"329 headers = {"Authorization": "abc"}330 response = client.get(url, headers=headers)335- assert response.url == httpx.URL("https://example.org/cross_domain_target")331+ assert response.url == "https://example.org/cross_domain_target"332 assert "authorization" not in response.json()["headers"]333 334 335 def test_same_domain_redirect():336 client = httpx.Client(transport=SyncMockTransport())337 url = "https://example.org/cross_domain"338 headers = {"Authorization": "abc"}339 response = client.get(url, headers=headers)344- assert response.url == httpx.URL("https://example.org/cross_domain_target")340+ assert response.url == "https://example.org/cross_domain_target"341 assert response.json()["headers"]["authorization"] == "abc"342 343 344 def test_body_redirect():3 unmodified lines348 client = httpx.Client(transport=SyncMockTransport())349 url = "https://example.org/redirect_body"350 data = b"Example request body"351 response = client.post(url, data=data)356- assert response.url == httpx.URL("https://example.org/redirect_body_target")352+ assert response.url == "https://example.org/redirect_body_target"353 assert response.json()["body"] == "Example request body"354 assert "content-length" in response.json()["headers"]355 356 4 unmodified lines361 client = httpx.Client(transport=SyncMockTransport())362 url = "https://example.org/redirect_no_body"363 data = b"Example request body"364 response = client.post(url, data=data)369- assert response.url == httpx.URL("https://example.org/redirect_body_target")365+ assert response.url == "https://example.org/redirect_body_target"366 assert response.json()["body"] == ""367 assert "content-length" not in response.json()["headers"]368 369 20 unmodified lines390 def test_cross_subdomain_redirect():391 client = httpx.Client(transport=SyncMockTransport())392 url = "https://example.com/cross_subdomain"393 response = client.get(url)398- assert response.url == httpx.URL("https://www.example.org/cross_subdomain")394+ assert response.url == "https://www.example.org/cross_subdomain"395 396 397 class MockCookieTransport(httpcore.SyncHTTPTransport):398 def request(82 unmodified lines