mirror of
https://github.com/jhd3197/ServerKit.git
synced 2026-10-30 08:36:55 +09:00
test_internal_error_handler_is_registered read app.error_handler_spec, a Flask internal whose shape has moved between releases, and proved only that something was registered. A handler can be registered and still return HTML or log nothing, so the test could not fail for either way the guarantee actually breaks. Now driven through app.handle_exception(), Flask's own entry point for an unhandled exception, asserting the response is JSON and that the request was logged. Not done by registering a route that raises: the `app` fixture is function-scoped but wraps a session-scoped Flask object, so the route would leak into every later test and collide on re-registration. PROPAGATE_EXCEPTIONS is forced off for the call because TESTING=True turns it on, which re-raises before any handler runs. The log assertion matches this handler's own wording rather than just the path. Flask's log_exception() already emits "Exception on /path [GET]" before any handler runs, so a path-only assertion passes even with the handler's logging deleted — confirmed by mutation, which is how the first version of this test was caught being vacuous. Both mutations (return HTML, drop the log) now fail, on different assertions. Raised by a reviewer on the PR. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>