Home / Function/ test_json_key_sorting() — flask Function Reference

test_json_key_sorting() — flask Function Reference

Architecture documentation for the test_json_key_sorting() function in test_json.py from the flask codebase.

Entity Profile

Dependency Diagram

graph TD
  fd543457_30c1_9cfe_c272_9146754dde20["test_json_key_sorting()"]
  f9bd76f2_7704_622d_4d31_ee892fa7fced["test_json.py"]
  fd543457_30c1_9cfe_c272_9146754dde20 -->|defined in| f9bd76f2_7704_622d_4d31_ee892fa7fced
  style fd543457_30c1_9cfe_c272_9146754dde20 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/test_json.py lines 270–337

def test_json_key_sorting(app, client):
    app.debug = True
    assert app.json.sort_keys
    d = dict.fromkeys(range(20), "foo")

    @app.route("/")
    def index():
        return flask.jsonify(values=d)

    rv = client.get("/")
    lines = [x.strip() for x in rv.data.strip().decode("utf-8").splitlines()]
    sorted_by_str = [
        "{",
        '"values": {',
        '"0": "foo",',
        '"1": "foo",',
        '"10": "foo",',
        '"11": "foo",',
        '"12": "foo",',
        '"13": "foo",',
        '"14": "foo",',
        '"15": "foo",',
        '"16": "foo",',
        '"17": "foo",',
        '"18": "foo",',
        '"19": "foo",',
        '"2": "foo",',
        '"3": "foo",',
        '"4": "foo",',
        '"5": "foo",',
        '"6": "foo",',
        '"7": "foo",',
        '"8": "foo",',
        '"9": "foo"',
        "}",
        "}",
    ]
    sorted_by_int = [
        "{",
        '"values": {',
        '"0": "foo",',
        '"1": "foo",',
        '"2": "foo",',
        '"3": "foo",',
        '"4": "foo",',
        '"5": "foo",',
        '"6": "foo",',
        '"7": "foo",',
        '"8": "foo",',
        '"9": "foo",',
        '"10": "foo",',
        '"11": "foo",',
        '"12": "foo",',
        '"13": "foo",',
        '"14": "foo",',
        '"15": "foo",',
        '"16": "foo",',
        '"17": "foo",',
        '"18": "foo",',
        '"19": "foo"',
        "}",
        "}",
    ]

    try:
        assert lines == sorted_by_int
    except AssertionError:
        assert lines == sorted_by_str

Subdomains

Defined In

Frequently Asked Questions

What does test_json_key_sorting() do?
test_json_key_sorting() is a function in the flask codebase, defined in tests/test_json.py.
Where is test_json_key_sorting() defined?
test_json_key_sorting() is defined in tests/test_json.py at line 270.

Analyze Your Own Codebase

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

Try Supermodel Free