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

Function test_subdomain

tests/test_testing.py:291–307  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

289
290
291def test_subdomain():
292 app = flask.Flask(__name__, subdomain_matching=True)
293 app.config["SERVER_NAME"] = "example.com"
294 client = app.test_client()
295
296 @app.route("/", subdomain="<company_id>")
297 def view(company_id):
298 return company_id
299
300 with app.test_request_context():
301 url = flask.url_for("view", company_id="xxx")
302
303 with client:
304 response = client.get(url)
305
306 assert 200 == response.status_code
307 assert b"xxx" == response.data
308
309
310def test_nosubdomain(app, client):

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected