@@ -31,20 +31,24 @@ async def test_client(client):
3131
3232
3333@pytest .mark .trio
34- async def test_get (client ):
35- async with ahttpx .serve_http (echo ) as server :
36- r = await client .get (server .url )
37- assert r .status_code == 200
38- assert r .body == b'{"method":"GET","query-params":{},"content-type":null,"json":null}'
39- # assert r.text == '{"method":"GET","query-params":{},"content-type":null,"json":null}'
34+ async def test_get (client , server ):
35+ r = await client .get (server .url )
36+ assert r .status_code == 200
37+ assert r .body == b'{"method":"GET","query-params":{},"content-type":null,"json":null}'
38+ assert r .content == {
39+ "method" : "GET" ,
40+ "query-params" : {},
41+ "content-type" : None ,
42+ "json" : None
43+ }
4044
4145
4246@pytest .mark .trio
4347async def test_post (client , server ):
4448 data = ahttpx .JSON ({"data" : 123 })
4549 r = await client .post (server .url , content = data )
4650 assert r .status_code == 200
47- assert json . loads ( r . body ) == {
51+ assert r . content == {
4852 'method' : 'POST' ,
4953 'query-params' : {},
5054 'content-type' : 'application/json' ,
@@ -57,7 +61,7 @@ async def test_put(client, server):
5761 data = ahttpx .JSON ({"data" : 123 })
5862 r = await client .put (server .url , content = data )
5963 assert r .status_code == 200
60- assert json . loads ( r . body ) == {
64+ assert r . content == {
6165 'method' : 'PUT' ,
6266 'query-params' : {},
6367 'content-type' : 'application/json' ,
@@ -70,7 +74,7 @@ async def test_patch(client, server):
7074 data = ahttpx .JSON ({"data" : 123 })
7175 r = await client .patch (server .url , content = data )
7276 assert r .status_code == 200
73- assert json . loads ( r . body ) == {
77+ assert r . content == {
7478 'method' : 'PATCH' ,
7579 'query-params' : {},
7680 'content-type' : 'application/json' ,
@@ -82,7 +86,7 @@ async def test_patch(client, server):
8286async def test_delete (client , server ):
8387 r = await client .delete (server .url )
8488 assert r .status_code == 200
85- assert json . loads ( r . body ) == {
89+ assert r . content == {
8690 'method' : 'DELETE' ,
8791 'query-params' : {},
8892 'content-type' : None ,
@@ -94,7 +98,7 @@ async def test_delete(client, server):
9498async def test_request (client , server ):
9599 r = await client .request ("GET" , server .url )
96100 assert r .status_code == 200
97- assert json . loads ( r . body ) == {
101+ assert r . content == {
98102 'method' : 'GET' ,
99103 'query-params' : {},
100104 'content-type' : None ,
0 commit comments