Home / Function/ test_json_decode_compatibility_for_alt_utf_encodings() — requests Function Reference

test_json_decode_compatibility_for_alt_utf_encodings() — requests Function Reference

Architecture documentation for the test_json_decode_compatibility_for_alt_utf_encodings() function in test_lowlevel.py from the requests codebase.

Entity Profile

Dependency Diagram

graph TD
  0b72fab6_7fcc_5b55_2836_f86522b9b99e["test_json_decode_compatibility_for_alt_utf_encodings()"]
  48561d17_8bd1_bf20_5710_ec3053a534d2["test_lowlevel.py"]
  0b72fab6_7fcc_5b55_2836_f86522b9b99e -->|defined in| 48561d17_8bd1_bf20_5710_ec3053a534d2
  7ab3c4d7_8531_6cbe_e871_9880cb1ee6de["consume_socket_content()"]
  0b72fab6_7fcc_5b55_2836_f86522b9b99e -->|calls| 7ab3c4d7_8531_6cbe_e871_9880cb1ee6de
  style 0b72fab6_7fcc_5b55_2836_f86522b9b99e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/test_lowlevel.py lines 407–428

def test_json_decode_compatibility_for_alt_utf_encodings():

    def response_handler(sock):
        consume_socket_content(sock, timeout=0.5)
        sock.send(
            b'HTTP/1.1 200 OK\r\n'
            b'Content-Length: 18\r\n\r\n'
            b'\xff\xfe{\x00"\x00K0"\x00=\x00"\x00\xab0"\x00\r\n'
        )

    close_server = threading.Event()
    server = Server(response_handler, wait_to_close_event=close_server)

    with server as (host, port):
        url = f'http://{host}:{port}/'
        r = requests.get(url)
    r.encoding = None
    with pytest.raises(requests.exceptions.JSONDecodeError) as excinfo:
        r.json()
    assert isinstance(excinfo.value, requests.exceptions.RequestException)
    assert isinstance(excinfo.value, JSONDecodeError)
    assert r.text not in str(excinfo.value)

Domain

Subdomains

Frequently Asked Questions

What does test_json_decode_compatibility_for_alt_utf_encodings() do?
test_json_decode_compatibility_for_alt_utf_encodings() is a function in the requests codebase, defined in tests/test_lowlevel.py.
Where is test_json_decode_compatibility_for_alt_utf_encodings() defined?
test_json_decode_compatibility_for_alt_utf_encodings() is defined in tests/test_lowlevel.py at line 407.
What does test_json_decode_compatibility_for_alt_utf_encodings() call?
test_json_decode_compatibility_for_alt_utf_encodings() calls 1 function(s): consume_socket_content.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free