]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Replace httpx.URL for str in tests (#1237)
authorEduardo Enriquez <eduardo.a.enriquez@gmail.com>
Sun, 30 Aug 2020 06:01:37 +0000 (08:01 +0200)
committerGitHub <noreply@github.com>
Sun, 30 Aug 2020 06:01:37 +0000 (08:01 +0200)
Co-authored-by: Eduardo Enriquez (eduzen) <eduardo.enriquez@freshbooks.com>
tests/client/test_client.py
tests/client/test_properties.py
tests/client/test_queryparams.py
tests/client/test_redirects.py

index 7d4bdd34411604374a11813e7d259b45f0d3731d..fe427ec66418aedf9d8416329ef89fb5872aa467 100644 (file)
@@ -178,7 +178,7 @@ def test_base_url(server):
 def test_merge_absolute_url():
     client = httpx.Client(base_url="https://www.example.com/")
     request = client.build_request("GET", "http://www.example.com/")
-    assert request.url == httpx.URL("http://www.example.com/")
+    assert request.url == "http://www.example.com/"
     with pytest.warns(DeprecationWarning):
         assert not request.url.is_ssl
 
@@ -186,19 +186,19 @@ def test_merge_absolute_url():
 def test_merge_relative_url():
     client = httpx.Client(base_url="https://www.example.com/")
     request = client.build_request("GET", "/testing/123")
-    assert request.url == httpx.URL("https://www.example.com/testing/123")
+    assert request.url == "https://www.example.com/testing/123"
 
 
 def test_merge_relative_url_with_path():
     client = httpx.Client(base_url="https://www.example.com/some/path")
     request = client.build_request("GET", "/testing/123")
-    assert request.url == httpx.URL("https://www.example.com/some/path/testing/123")
+    assert request.url == "https://www.example.com/some/path/testing/123"
 
 
 def test_merge_relative_url_with_dotted_path():
     client = httpx.Client(base_url="https://www.example.com/some/path")
     request = client.build_request("GET", "../testing/123")
-    assert request.url == httpx.URL("https://www.example.com/some/testing/123")
+    assert request.url == "https://www.example.com/some/testing/123"
 
 
 def test_pool_limits_deprecated():
index 35d4e376d35834057da086bc06eed2f2a71cfb9f..cb6ee3285167e2076e742999a330426387b0f2dc 100644 (file)
@@ -5,21 +5,21 @@ def test_client_base_url():
     client = httpx.Client()
     client.base_url = "https://www.example.org/"  # type: ignore
     assert isinstance(client.base_url, httpx.URL)
-    assert client.base_url == httpx.URL("https://www.example.org/")
+    assert client.base_url == "https://www.example.org/"
 
 
 def test_client_base_url_without_trailing_slash():
     client = httpx.Client()
     client.base_url = "https://www.example.org/path"  # type: ignore
     assert isinstance(client.base_url, httpx.URL)
-    assert client.base_url == httpx.URL("https://www.example.org/path/")
+    assert client.base_url == "https://www.example.org/path/"
 
 
 def test_client_base_url_with_trailing_slash():
     client = httpx.Client()
     client.base_url = "https://www.example.org/path/"  # type: ignore
     assert isinstance(client.base_url, httpx.URL)
-    assert client.base_url == httpx.URL("https://www.example.org/path/")
+    assert client.base_url == "https://www.example.org/path/"
 
 
 def test_client_headers():
index 68b936d051ad2014980a8fa4c2563d7cfaf97720..22f715dadc2fa610461b45a99c9bd176ba3b1121 100644 (file)
@@ -46,6 +46,4 @@ def test_client_queryparams_echo():
     response = client.get(url, params=request_queryparams)
 
     assert response.status_code == 200
-    assert response.url == httpx.URL(
-        "http://example.org/echo_queryparams?first=str&second=dict"
-    )
+    assert response.url == "http://example.org/echo_queryparams?first=str&second=dict"
index 7fc8d766749ff2fda174c63f70d9dc6d99dcafed..b18feee95b9404779064aab9f7bd4b36f191d189 100644 (file)
@@ -186,7 +186,7 @@ def test_redirect_301():
     client = httpx.Client(transport=SyncMockTransport())
     response = client.post("https://example.org/redirect_301")
     assert response.status_code == httpx.codes.OK
-    assert response.url == httpx.URL("https://example.org/")
+    assert response.url == "https://example.org/"
     assert len(response.history) == 1
 
 
@@ -194,7 +194,7 @@ def test_redirect_302():
     client = httpx.Client(transport=SyncMockTransport())
     response = client.post("https://example.org/redirect_302")
     assert response.status_code == httpx.codes.OK
-    assert response.url == httpx.URL("https://example.org/")
+    assert response.url == "https://example.org/"
     assert len(response.history) == 1
 
 
@@ -202,7 +202,7 @@ def test_redirect_303():
     client = httpx.Client(transport=SyncMockTransport())
     response = client.get("https://example.org/redirect_303")
     assert response.status_code == httpx.codes.OK
-    assert response.url == httpx.URL("https://example.org/")
+    assert response.url == "https://example.org/"
     assert len(response.history) == 1
 
 
@@ -210,13 +210,13 @@ def test_disallow_redirects():
     client = httpx.Client(transport=SyncMockTransport())
     response = client.post("https://example.org/redirect_303", allow_redirects=False)
     assert response.status_code == httpx.codes.SEE_OTHER
-    assert response.url == httpx.URL("https://example.org/redirect_303")
+    assert response.url == "https://example.org/redirect_303"
     assert response.is_redirect is True
     assert len(response.history) == 0
 
     response = response.next()
     assert response.status_code == httpx.codes.OK
-    assert response.url == httpx.URL("https://example.org/")
+    assert response.url == "https://example.org/"
     assert response.is_redirect is False
     assert len(response.history) == 1
 
@@ -228,7 +228,7 @@ def test_head_redirect():
     client = httpx.Client(transport=SyncMockTransport())
     response = client.head("https://example.org/redirect_302")
     assert response.status_code == httpx.codes.OK
-    assert response.url == httpx.URL("https://example.org/")
+    assert response.url == "https://example.org/"
     assert response.request.method == "HEAD"
     assert len(response.history) == 1
     assert response.text == ""
@@ -238,7 +238,7 @@ def test_relative_redirect():
     client = httpx.Client(transport=SyncMockTransport())
     response = client.get("https://example.org/relative_redirect")
     assert response.status_code == httpx.codes.OK
-    assert response.url == httpx.URL("https://example.org/")
+    assert response.url == "https://example.org/"
     assert len(response.history) == 1
 
 
@@ -247,7 +247,7 @@ def test_malformed_redirect():
     client = httpx.Client(transport=SyncMockTransport())
     response = client.get("http://example.org/malformed_redirect")
     assert response.status_code == httpx.codes.OK
-    assert response.url == httpx.URL("https://example.org:443/")
+    assert response.url == "https://example.org:443/"
     assert len(response.history) == 1
 
 
@@ -261,7 +261,7 @@ def test_no_scheme_redirect():
     client = httpx.Client(transport=SyncMockTransport())
     response = client.get("https://example.org/no_scheme_redirect")
     assert response.status_code == httpx.codes.OK
-    assert response.url == httpx.URL("https://example.org/")
+    assert response.url == "https://example.org/"
     assert len(response.history) == 1
 
 
@@ -269,7 +269,7 @@ def test_fragment_redirect():
     client = httpx.Client(transport=SyncMockTransport())
     response = client.get("https://example.org/relative_redirect#fragment")
     assert response.status_code == httpx.codes.OK
-    assert response.url == httpx.URL("https://example.org/#fragment")
+    assert response.url == "https://example.org/#fragment"
     assert len(response.history) == 1
 
 
@@ -277,14 +277,10 @@ def test_multiple_redirects():
     client = httpx.Client(transport=SyncMockTransport())
     response = client.get("https://example.org/multiple_redirects?count=20")
     assert response.status_code == httpx.codes.OK
-    assert response.url == httpx.URL("https://example.org/multiple_redirects")
+    assert response.url == "https://example.org/multiple_redirects"
     assert len(response.history) == 20
-    assert response.history[0].url == httpx.URL(
-        "https://example.org/multiple_redirects?count=20"
-    )
-    assert response.history[1].url == httpx.URL(
-        "https://example.org/multiple_redirects?count=19"
-    )
+    assert response.history[0].url == "https://example.org/multiple_redirects?count=20"
+    assert response.history[1].url == "https://example.org/multiple_redirects?count=19"
     assert len(response.history[0].history) == 0
     assert len(response.history[1].history) == 1
 
@@ -332,7 +328,7 @@ def test_cross_domain_redirect():
     url = "https://example.com/cross_domain"
     headers = {"Authorization": "abc"}
     response = client.get(url, headers=headers)
-    assert response.url == httpx.URL("https://example.org/cross_domain_target")
+    assert response.url == "https://example.org/cross_domain_target"
     assert "authorization" not in response.json()["headers"]
 
 
@@ -341,7 +337,7 @@ def test_same_domain_redirect():
     url = "https://example.org/cross_domain"
     headers = {"Authorization": "abc"}
     response = client.get(url, headers=headers)
-    assert response.url == httpx.URL("https://example.org/cross_domain_target")
+    assert response.url == "https://example.org/cross_domain_target"
     assert response.json()["headers"]["authorization"] == "abc"
 
 
@@ -353,7 +349,7 @@ def test_body_redirect():
     url = "https://example.org/redirect_body"
     data = b"Example request body"
     response = client.post(url, data=data)
-    assert response.url == httpx.URL("https://example.org/redirect_body_target")
+    assert response.url == "https://example.org/redirect_body_target"
     assert response.json()["body"] == "Example request body"
     assert "content-length" in response.json()["headers"]
 
@@ -366,7 +362,7 @@ def test_no_body_redirect():
     url = "https://example.org/redirect_no_body"
     data = b"Example request body"
     response = client.post(url, data=data)
-    assert response.url == httpx.URL("https://example.org/redirect_body_target")
+    assert response.url == "https://example.org/redirect_body_target"
     assert response.json()["body"] == ""
     assert "content-length" not in response.json()["headers"]
 
@@ -395,7 +391,7 @@ def test_cross_subdomain_redirect():
     client = httpx.Client(transport=SyncMockTransport())
     url = "https://example.com/cross_subdomain"
     response = client.get(url)
-    assert response.url == httpx.URL("https://www.example.org/cross_subdomain")
+    assert response.url == "https://www.example.org/cross_subdomain"
 
 
 class MockCookieTransport(httpcore.SyncHTTPTransport):