Skip to content
Myr

Avoid private imports in test cases. (#3403)

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 2ea2286 · Browse files · 1 file+8 added−13 removed
This commit

State

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

Diff stats

1 file+8 added−13 removed

  • tests:+8 added−13 removed

1 file+8 added−13 removed

modified:tests/test_content.py+8 added-13 removed
2 unmodified lines
34import pytest56import httpx7from httpx._content import encode_json78method = "POST"9url = "https://www.example.com"10
476 unmodified lines
487488489def test_ensure_ascii_false_with_french_characters():490 data = {"greeting": "Bonjour, ça va ?"}492 headers, byte_stream = encode_json(data)493 json_output = b"".join(byte_stream).decode("utf-8")494491 response = httpx.Response(200, json=data)492 assert (496 "ça va" in json_output493 "ça va" in response.text494 ), "ensure_ascii=False should preserve French accented characters"498 assert headers["Content-Type"] == "application/json"495 assert response.headers["Content-Type"] == "application/json"496497498def test_separators_for_compact_json():499 data = {"clé": "valeur", "liste": [1, 2, 3]}503 headers, byte_stream = encode_json(data)504 json_output = b"".join(byte_stream).decode("utf-8")505500 response = httpx.Response(200, json=data)501 assert (507 json_output == '{"clé":"valeur","liste":[1,2,3]}'502 response.text == '{"clé":"valeur","liste":[1,2,3]}'503 ), "separators=(',', ':') should produce a compact representation"509 assert headers["Content-Type"] == "application/json"504 assert response.headers["Content-Type"] == "application/json"505506507def test_allow_nan_false():508 data_with_nan = {"nombre": float("nan")}
1 unmodified line
510511 with pytest.raises(512 ValueError, match="Out of range float values are not JSON compliant"513 ):519 encode_json(data_with_nan)514 httpx.Response(200, json=data_with_nan)515 with pytest.raises(516 ValueError, match="Out of range float values are not JSON compliant"517 ):523 encode_json(data_with_inf)518 httpx.Response(200, json=data_with_inf)