Skip to content
Myr

test_connections.py

This file

Path

tests/dispatch/test_connections.py

51 lines · 1.9 KiB · Python

Last changed by

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

History of this file

Take it

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

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

line 1why, one step back
1import pytest

Release semaphore if connection is dropped (#230)Ordanis Sanchezbefore adoptiona960a2a

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

Release semaphore if connection is dropped (#230)Ordanis Sanchezbefore adoptiona960a2a

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):

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

lines 8–9why, one step back
8 async with HTTPConnection(origin=server.url, backend=backend) as conn:
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!"

Release semaphore if connection is dropped (#230)Ordanis Sanchezbefore adoptiona960a2a

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):

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

lines 16–17why, one step back
16 async with HTTPConnection(origin=server.url, backend=backend) as conn:
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):

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

lines 23–27why, one step back
23 async with HTTPConnection(origin=server.url, backend=backend) as conn:
24 response = await conn.request(25 "GET", server.url.copy_with(path="/premature_close")26 )27 await response.read()

Release semaphore if connection is dropped (#230)Ordanis Sanchezbefore adoptiona960a2a

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):

Release semaphore if connection is dropped (#230)Ordanis Sanchezbefore adoptiona960a2a

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

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

line 34why, one step back
34 async with HTTPConnection(

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

line 35why, one step back
35 origin=https_server.url, verify=ca_cert_pem_file, backend=backend

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

line 36why, one step back
36 ) as conn:

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

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

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

lines 38–40why, one step back
38 await response.read()
39 assert response.status_code == 20040 assert response.content == b"Hello, world!"

Release semaphore if connection is dropped (#230)Ordanis Sanchezbefore adoptiona960a2a

lines 41–42why, one step back
41
42

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

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

Release semaphore if connection is dropped (#230)Ordanis Sanchezbefore adoptiona960a2a

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

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

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

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

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

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

lines 49–51why, one step back
49 await response.read()
50 assert response.status_code == 20051 assert response.content == b"Hello, world!"