Skip to content
Myr

Parameterize invalid URL tests (#1079)

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

authored by Tom Christie · committed by GitHub · parent 7e6e351 · Browse files · 2 files+20 added−12 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+20 added−12 removed

  • tests:+20 added−12 removed

2 files+20 added−12 removed

modified:tests/client/test_async_client.py+10 added-6 removed
16 unmodified lines
17 assert repr(response) == "<Response [200 OK]>"18 assert response.elapsed > timedelta(seconds=0)192021@pytest.mark.parametrize(22 "url",23 [24 pytest.param("invalid://example.org", id="scheme-not-http(s)"),25 pytest.param("://example.org", id="no-scheme"),26 pytest.param("http://", id="no-host"),27 ],28)29@pytest.mark.usefixtures("async_environment")22async def test_get_invalid_url(server):30async def test_get_invalid_url(server, url):31 async with httpx.AsyncClient() as client:32 with pytest.raises(httpx.InvalidURL):25 await client.get("invalid://example.org")26 with pytest.raises(httpx.InvalidURL):27 await client.get("://example.org")28 with pytest.raises(httpx.InvalidURL):29 await client.get("http://")33 await client.get(url)343536@pytest.mark.usefixtures("async_environment")37async def test_build_request(server):
128 unmodified lines
modified:tests/client/test_client.py+10 added-6 removed
20 unmodified lines
21 assert repr(response) == "<Response [200 OK]>"22 assert response.elapsed > timedelta(0)232425@pytest.mark.parametrize(26 "url",27 [28 pytest.param("invalid://example.org", id="scheme-not-http(s)"),29 pytest.param("://example.org", id="no-scheme"),30 pytest.param("http://", id="no-host"),31 ],32)25def test_get_invalid_url(server):33def test_get_invalid_url(server, url):34 with httpx.Client() as client:35 with pytest.raises(httpx.InvalidURL):28 client.get("invalid://example.org")29 with pytest.raises(httpx.InvalidURL):30 client.get("://example.org")31 with pytest.raises(httpx.InvalidURL):32 client.get("http://")36 client.get(url)373839def test_build_request(server):40 url = server.url.copy_with(path="/echo_headers")
153 unmodified lines