Home / Class/ TestContentEncodingDetection Class — requests Architecture

TestContentEncodingDetection Class — requests Architecture

Architecture documentation for the TestContentEncodingDetection class in test_utils.py from the requests codebase.

Entity Profile

Dependency Diagram

graph TD
  7b9bc687_6c61_d56e_8a1d_71fe58dce6c4["TestContentEncodingDetection"]
  5828793e_be5b_8952_37f1_338fd4634a1a["test_utils.py"]
  7b9bc687_6c61_d56e_8a1d_71fe58dce6c4 -->|defined in| 5828793e_be5b_8952_37f1_338fd4634a1a
  546956a2_065f_8d33_3a11_b1c09327c2a6["test_none()"]
  7b9bc687_6c61_d56e_8a1d_71fe58dce6c4 -->|method| 546956a2_065f_8d33_3a11_b1c09327c2a6
  587fdc00_1be3_40bd_d909_599c083a320d["test_pragmas()"]
  7b9bc687_6c61_d56e_8a1d_71fe58dce6c4 -->|method| 587fdc00_1be3_40bd_d909_599c083a320d
  6d1238ca_b541_a999_6f12_3540125871b0["test_precedence()"]
  7b9bc687_6c61_d56e_8a1d_71fe58dce6c4 -->|method| 6d1238ca_b541_a999_6f12_3540125871b0

Relationship Graph

Source Code

tests/test_utils.py lines 363–392

class TestContentEncodingDetection:
    def test_none(self):
        encodings = get_encodings_from_content("")
        assert not len(encodings)

    @pytest.mark.parametrize(
        "content",
        (
            # HTML5 meta charset attribute
            '<meta charset="UTF-8">',
            # HTML4 pragma directive
            '<meta http-equiv="Content-type" content="text/html;charset=UTF-8">',
            # XHTML 1.x served with text/html MIME type
            '<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />',
            # XHTML 1.x served as XML
            '<?xml version="1.0" encoding="UTF-8"?>',
        ),
    )
    def test_pragmas(self, content):
        encodings = get_encodings_from_content(content)
        assert len(encodings) == 1
        assert encodings[0] == "UTF-8"

    def test_precedence(self):
        content = """
        <?xml version="1.0" encoding="XML"?>
        <meta charset="HTML5">
        <meta http-equiv="Content-type" content="text/html;charset=HTML4" />
        """.strip()
        assert get_encodings_from_content(content) == ["HTML5", "HTML4", "XML"]

Domain

Defined In

Frequently Asked Questions

What is the TestContentEncodingDetection class?
TestContentEncodingDetection is a class in the requests codebase, defined in tests/test_utils.py.
Where is TestContentEncodingDetection defined?
TestContentEncodingDetection is defined in tests/test_utils.py at line 363.

Analyze Your Own Codebase

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

Try Supermodel Free