MCPcopy
hub / github.com/pallets/flask / test_static_route_with_host_matching

Function test_static_route_with_host_matching

tests/test_basic.py:1489–1507  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1487
1488
1489def test_static_route_with_host_matching():
1490 app = flask.Flask(__name__, host_matching=True, static_host="example.com")
1491 c = app.test_client()
1492 rv = c.get("http://example.com/static/index.html")
1493 assert rv.status_code == 200
1494 rv.close()
1495 with app.test_request_context():
1496 rv = flask.url_for("static", filename="index.html", _external=True)
1497 assert rv == "http://example.com/static/index.html"
1498 # Providing static_host without host_matching=True should error.
1499 with pytest.raises(AssertionError):
1500 flask.Flask(__name__, static_host="example.com")
1501 # Providing host_matching=True with static_folder
1502 # but without static_host should error.
1503 with pytest.raises(AssertionError):
1504 flask.Flask(__name__, host_matching=True)
1505 # Providing host_matching=True without static_host
1506 # but with static_folder=None should not error.
1507 flask.Flask(__name__, host_matching=True, static_folder=None)
1508
1509
1510def test_request_locals():

Callers

nothing calls this directly

Calls 5

test_clientMethod · 0.95
test_request_contextMethod · 0.95
closeMethod · 0.80
url_forMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected