Home / Function/ test_server_name_matching() — flask Function Reference

test_server_name_matching() — flask Function Reference

Architecture documentation for the test_server_name_matching() function in test_basic.py from the flask codebase.

Entity Profile

Dependency Diagram

graph TD
  b8a1ef67_4734_9deb_74d1_6eeffb181e03["test_server_name_matching()"]
  85bc4fb5_d1d7_a135_020d_69e052c12c0f["test_basic.py"]
  b8a1ef67_4734_9deb_74d1_6eeffb181e03 -->|defined in| 85bc4fb5_d1d7_a135_020d_69e052c12c0f
  6ea1611d_2801_3cb5_a5b9_5b6403cc0537["index()"]
  b8a1ef67_4734_9deb_74d1_6eeffb181e03 -->|calls| 6ea1611d_2801_3cb5_a5b9_5b6403cc0537
  style b8a1ef67_4734_9deb_74d1_6eeffb181e03 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/test_basic.py lines 1505–1538

def test_server_name_matching(
    subdomain_matching: bool,
    host_matching: bool,
    expect_subdomain: str,
    expect_host: str,
) -> None:
    app = flask.Flask(
        __name__,
        subdomain_matching=subdomain_matching,
        host_matching=host_matching,
        static_host="example.test" if host_matching else None,
    )
    app.config["SERVER_NAME"] = "example.test"

    @app.route("/", defaults={"name": "default"}, host="<name>")
    @app.route("/", subdomain="<name>", host="<name>.example.test")
    def index(name: str) -> str:
        return name

    client = app.test_client()

    r = client.get(base_url="http://example.test")
    assert r.text == "default"

    r = client.get(base_url="http://abc.example.test")
    assert r.text == expect_subdomain

    with pytest.warns() if subdomain_matching else nullcontext():
        r = client.get(base_url="http://xyz.other.test")

        if werkzeug_3_2:
            assert r.text == "default"
        else:
            assert r.text == expect_host

Subdomains

Defined In

Calls

Frequently Asked Questions

What does test_server_name_matching() do?
test_server_name_matching() is a function in the flask codebase, defined in tests/test_basic.py.
Where is test_server_name_matching() defined?
test_server_name_matching() is defined in tests/test_basic.py at line 1505.
What does test_server_name_matching() call?
test_server_name_matching() calls 1 function(s): index.

Analyze Your Own Codebase

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

Try Supermodel Free