|
1 | 1 | from datetime import timedelta |
2 | 2 |
|
| 3 | +import httpcore |
3 | 4 | import pytest |
4 | 5 |
|
5 | 6 | import httpx |
| 7 | +from httpx import WSGIDispatch |
6 | 8 |
|
7 | 9 |
|
8 | 10 | def test_get(server): |
@@ -103,12 +105,13 @@ def test_raise_for_status(server): |
103 | 105 | with httpx.Client() as client: |
104 | 106 | for status_code in (200, 400, 404, 500, 505): |
105 | 107 | response = client.request( |
106 | | - "GET", server.url.copy_with(path="/status/{}".format(status_code)) |
| 108 | + "GET", server.url.copy_with(path=f"/status/{status_code}") |
107 | 109 | ) |
108 | 110 | if 400 <= status_code < 600: |
109 | 111 | with pytest.raises(httpx.HTTPError) as exc_info: |
110 | 112 | response.raise_for_status() |
111 | 113 | assert exc_info.value.response == response |
| 114 | + assert exc_info.value.request.url.path == f"/status/{status_code}" |
112 | 115 | else: |
113 | 116 | assert response.raise_for_status() is None # type: ignore |
114 | 117 |
|
@@ -162,3 +165,28 @@ def test_merge_url(): |
162 | 165 |
|
163 | 166 | assert url.scheme == "https" |
164 | 167 | assert url.is_ssl |
| 168 | + |
| 169 | + |
| 170 | +def test_dispatch_deprecated(): |
| 171 | + dispatch = httpcore.SyncHTTPTransport() |
| 172 | + |
| 173 | + with pytest.warns(DeprecationWarning) as record: |
| 174 | + client = httpx.Client(dispatch=dispatch) |
| 175 | + |
| 176 | + assert client.transport is dispatch |
| 177 | + assert len(record) == 1 |
| 178 | + assert record[0].message.args[0] == ( |
| 179 | + "The dispatch argument is deprecated since v0.13 and will be " |
| 180 | + "removed in a future release, please use 'transport'" |
| 181 | + ) |
| 182 | + |
| 183 | + |
| 184 | +def test_wsgi_dispatch_deprecated(): |
| 185 | + with pytest.warns(DeprecationWarning) as record: |
| 186 | + WSGIDispatch(None) |
| 187 | + |
| 188 | + assert len(record) == 1 |
| 189 | + assert ( |
| 190 | + record[0].message.args[0] |
| 191 | + == "WSGIDispatch is deprecated, please use WSGITransport" |
| 192 | + ) |
0 commit comments