44import pytest
55
66import httpx
7- from httpx ._content import encode_json
87
98method = "POST"
109url = "https://www.example.com"
@@ -489,24 +488,20 @@ def test_response_invalid_argument():
489488
490489def test_ensure_ascii_false_with_french_characters ():
491490 data = {"greeting" : "Bonjour, ça va ?" }
492- headers , byte_stream = encode_json (data )
493- json_output = b"" .join (byte_stream ).decode ("utf-8" )
494-
491+ response = httpx .Response (200 , json = data )
495492 assert (
496- "ça va" in json_output
493+ "ça va" in response . text
497494 ), "ensure_ascii=False should preserve French accented characters"
498- assert headers ["Content-Type" ] == "application/json"
495+ assert response . headers ["Content-Type" ] == "application/json"
499496
500497
501498def test_separators_for_compact_json ():
502499 data = {"clé" : "valeur" , "liste" : [1 , 2 , 3 ]}
503- headers , byte_stream = encode_json (data )
504- json_output = b"" .join (byte_stream ).decode ("utf-8" )
505-
500+ response = httpx .Response (200 , json = data )
506501 assert (
507- json_output == '{"clé":"valeur","liste":[1,2,3]}'
502+ response . text == '{"clé":"valeur","liste":[1,2,3]}'
508503 ), "separators=(',', ':') should produce a compact representation"
509- assert headers ["Content-Type" ] == "application/json"
504+ assert response . headers ["Content-Type" ] == "application/json"
510505
511506
512507def test_allow_nan_false ():
@@ -516,8 +511,8 @@ def test_allow_nan_false():
516511 with pytest .raises (
517512 ValueError , match = "Out of range float values are not JSON compliant"
518513 ):
519- encode_json ( data_with_nan )
514+ httpx . Response ( 200 , json = data_with_nan )
520515 with pytest .raises (
521516 ValueError , match = "Out of range float values are not JSON compliant"
522517 ):
523- encode_json ( data_with_inf )
518+ httpx . Response ( 200 , json = data_with_inf )
0 commit comments