(app)
| 61 | |
| 62 | |
| 63 | def test_proper_test_request_context(app): |
| 64 | app.config.update(SERVER_NAME="localhost.localdomain:5000") |
| 65 | |
| 66 | @app.route("/") |
| 67 | def index(): |
| 68 | return None |
| 69 | |
| 70 | @app.route("/", subdomain="foo") |
| 71 | def sub(): |
| 72 | return None |
| 73 | |
| 74 | with app.test_request_context("/"): |
| 75 | assert ( |
| 76 | flask.url_for("index", _external=True) |
| 77 | == "http://localhost.localdomain:5000/" |
| 78 | ) |
| 79 | |
| 80 | with app.test_request_context("/"): |
| 81 | assert ( |
| 82 | flask.url_for("sub", _external=True) |
| 83 | == "http://foo.localhost.localdomain:5000/" |
| 84 | ) |
| 85 | |
| 86 | # suppress Werkzeug 0.15 warning about name mismatch |
| 87 | with warnings.catch_warnings(): |
| 88 | warnings.filterwarnings( |
| 89 | "ignore", "Current server name", UserWarning, "flask.app" |
| 90 | ) |
| 91 | with app.test_request_context( |
| 92 | "/", environ_overrides={"HTTP_HOST": "localhost"} |
| 93 | ): |
| 94 | pass |
| 95 | |
| 96 | app.config.update(SERVER_NAME="localhost") |
| 97 | with app.test_request_context("/", environ_overrides={"SERVER_NAME": "localhost"}): |
| 98 | pass |
| 99 | |
| 100 | app.config.update(SERVER_NAME="localhost:80") |
| 101 | with app.test_request_context( |
| 102 | "/", environ_overrides={"SERVER_NAME": "localhost:80"} |
| 103 | ): |
| 104 | pass |
| 105 | |
| 106 | |
| 107 | def test_context_binding(app): |
nothing calls this directly
no test coverage detected