Skip to content
Myr

test_connections.py

This file

Path

tests/dispatch/test_connections.py

49 lines · 1.8 KiB · Python

Last changed by

Refactor tests in the light of backend auto-detection (#615)Florimond Mancabefore adoptionab41a5d

History of this file

Take it

The walk stopped after 200 commits: lines older than 20cb8af point at it.

Handle h11.Connection.next_event() RemoteProtocolError (#524)toppkbefore adoptionf06ca87

line 1why, one step back
1import pytest

Travis sudo no longer required for Xenial (#266)Hugo van Kemenadebefore adoption20cb8af

line 2why, one step back
2

Tighten up top-level API to only expose public API (#608)Tom Christiebefore adoptiond15dc0b

lines 3–4why, one step back
3import httpx
4from httpx.dispatch.connection import HTTPConnection

Travis sudo no longer required for Xenial (#266)Hugo van Kemenadebefore adoption20cb8af

line 5why, one step back
5

Handle h11.Connection.next_event() RemoteProtocolError (#524)toppkbefore adoptionf06ca87

line 6why, one step back
6

Parametrize tests with concurrency backend (#273)Florimond Mancabefore adoption3674058

line 7why, one step back
7async def test_get(server, backend):

Refactor tests in the light of backend auto-detection (#615)Florimond Mancabefore adoptionab41a5d

line 8why, one step back
8 async with HTTPConnection(origin=server.url) as conn:

Add server.url property in tests (#300)Bakhtiyor Ruzievbefore adoptione34d280

line 9why, one step back
9 response = await conn.request("GET", server.url)

Serve test server in thread (#292)Florimond Mancabefore adoption994403b

lines 10–12why, one step back
10 await response.read()
11 assert response.status_code == 20012 assert response.content == b"Hello, world!"

Travis sudo no longer required for Xenial (#266)Hugo van Kemenadebefore adoption20cb8af

lines 13–14why, one step back
13
14

Parametrize tests with concurrency backend (#273)Florimond Mancabefore adoption3674058

line 15why, one step back
15async def test_post(server, backend):

Refactor tests in the light of backend auto-detection (#615)Florimond Mancabefore adoptionab41a5d

line 16why, one step back
16 async with HTTPConnection(origin=server.url) as conn:

Add server.url property in tests (#300)Bakhtiyor Ruzievbefore adoptione34d280

line 17why, one step back
17 response = await conn.request("GET", server.url, data=b"Hello, world!")

Serve test server in thread (#292)Florimond Mancabefore adoption994403b

line 18why, one step back
18 assert response.status_code == 200

Handle h11.Connection.next_event() RemoteProtocolError (#524)toppkbefore adoptionf06ca87

lines 19–21why, one step back
19
2021async def test_premature_close(server, backend):

Tighten up top-level API to only expose public API (#608)Tom Christiebefore adoptiond15dc0b

line 22why, one step back
22 with pytest.raises(httpx.ConnectionClosed):

Refactor tests in the light of backend auto-detection (#615)Florimond Mancabefore adoptionab41a5d

line 23why, one step back
23 async with HTTPConnection(origin=server.url) as conn:

Handle h11.Connection.next_event() RemoteProtocolError (#524)toppkbefore adoptionf06ca87

lines 24–27why, one step back
24 response = await conn.request(
25 "GET", server.url.copy_with(path="/premature_close")26 )27 await response.read()

Travis sudo no longer required for Xenial (#266)Hugo van Kemenadebefore adoption20cb8af

lines 28–29why, one step back
28
29

Use a certificate issued from the trustme CA in tests (#357)Jamie Hewlandbefore adoption338a360

line 30why, one step back
30async def test_https_get_with_ssl_defaults(https_server, ca_cert_pem_file, backend):

Travis sudo no longer required for Xenial (#266)Hugo van Kemenadebefore adoption20cb8af

lines 31–33why, one step back
31 """
32 An HTTPS request, with default SSL configuration set on the client.33 """

Refactor tests in the light of backend auto-detection (#615)Florimond Mancabefore adoptionab41a5d

line 34why, one step back
34 async with HTTPConnection(origin=https_server.url, verify=ca_cert_pem_file) as conn:

Add server.url property in tests (#300)Bakhtiyor Ruzievbefore adoptione34d280

line 35why, one step back
35 response = await conn.request("GET", https_server.url)

Serve test server in thread (#292)Florimond Mancabefore adoption994403b

lines 36–38why, one step back
36 await response.read()
37 assert response.status_code == 20038 assert response.content == b"Hello, world!"

Travis sudo no longer required for Xenial (#266)Hugo van Kemenadebefore adoption20cb8af

lines 39–40why, one step back
39
40

Use a certificate issued from the trustme CA in tests (#357)Jamie Hewlandbefore adoption338a360

line 41why, one step back
41async def test_https_get_with_sll_overrides(https_server, ca_cert_pem_file, backend):

Travis sudo no longer required for Xenial (#266)Hugo van Kemenadebefore adoption20cb8af

lines 42–44why, one step back
42 """
43 An HTTPS request, with SSL configuration set on the request.44 """

Refactor tests in the light of backend auto-detection (#615)Florimond Mancabefore adoptionab41a5d

line 45why, one step back
45 async with HTTPConnection(origin=https_server.url) as conn:

Use a certificate issued from the trustme CA in tests (#357)Jamie Hewlandbefore adoption338a360

line 46why, one step back
46 response = await conn.request("GET", https_server.url, verify=ca_cert_pem_file)

Serve test server in thread (#292)Florimond Mancabefore adoption994403b

lines 47–49why, one step back
47 await response.read()
48 assert response.status_code == 20049 assert response.content == b"Hello, world!"