(app)
| 1342 | |
| 1343 | |
| 1344 | def test_build_error_handler(app): |
| 1345 | # Test base case, a URL which results in a BuildError. |
| 1346 | with app.test_request_context(): |
| 1347 | pytest.raises(BuildError, flask.url_for, "spam") |
| 1348 | |
| 1349 | # Verify the error is re-raised if not the current exception. |
| 1350 | try: |
| 1351 | with app.test_request_context(): |
| 1352 | flask.url_for("spam") |
| 1353 | except BuildError as err: |
| 1354 | error = err |
| 1355 | try: |
| 1356 | raise RuntimeError("Test case where BuildError is not current.") |
| 1357 | except RuntimeError: |
| 1358 | pytest.raises(BuildError, app.handle_url_build_error, error, "spam", {}) |
| 1359 | |
| 1360 | # Test a custom handler. |
| 1361 | def handler(error, endpoint, values): |
| 1362 | # Just a test. |
| 1363 | return "/test_handler/" |
| 1364 | |
| 1365 | app.url_build_error_handlers.append(handler) |
| 1366 | with app.test_request_context(): |
| 1367 | assert flask.url_for("spam") == "/test_handler/" |
| 1368 | |
| 1369 | |
| 1370 | def test_build_error_handler_reraise(app): |
nothing calls this directly
no test coverage detected