(app)
| 1370 | |
| 1371 | |
| 1372 | def test_build_error_handler(app): |
| 1373 | # Test base case, a URL which results in a BuildError. |
| 1374 | with app.test_request_context(): |
| 1375 | pytest.raises(BuildError, flask.url_for, "spam") |
| 1376 | |
| 1377 | # Verify the error is re-raised if not the current exception. |
| 1378 | try: |
| 1379 | with app.test_request_context(): |
| 1380 | flask.url_for("spam") |
| 1381 | except BuildError as err: |
| 1382 | error = err |
| 1383 | try: |
| 1384 | raise RuntimeError("Test case where BuildError is not current.") |
| 1385 | except RuntimeError: |
| 1386 | pytest.raises(BuildError, app.handle_url_build_error, error, "spam", {}) |
| 1387 | |
| 1388 | # Test a custom handler. |
| 1389 | def handler(error, endpoint, values): |
| 1390 | # Just a test. |
| 1391 | return "/test_handler/" |
| 1392 | |
| 1393 | app.url_build_error_handlers.append(handler) |
| 1394 | with app.test_request_context(): |
| 1395 | assert flask.url_for("spam") == "/test_handler/" |
| 1396 | |
| 1397 | |
| 1398 | def test_build_error_handler_reraise(app): |
nothing calls this directly
no test coverage detected