Repository navigation
test: add tests for example apps - #65
Merged
Merged
Conversation
JacobCoffee
force-pushed
the
test/example-apps
branch
from
October 11, 2026 01:21
35d0b1f to
90626b4
Compare
…ample
DELETE /api/users/{id} raised a 500 IntegrityError for any user with
posts, since the default relationship behaviour nulls out the foreign
key instead of deleting dependents, and Post.author_id is non-nullable.
Found while writing tests for the example app.
Add tests/examples/ covering every app under examples/: asgi_basic, litestar_basic, litestar_advanced_alchemy, starlette_basic, fastapi_basic, websocket_panel_example, graphql_panel_example, mcp_server_example, and the standalone panel demo scripts (cache, templates, settings, profiling, memory, flamegraph, async_profiler, alerts). Each app is exercised through its own framework's real test client: documented routes are checked for status/content-type, toolbar HTML injection and static assets, and the per-request panel data the example is built to demonstrate (SQL N+1 detection, GraphQL resolver tracking, websocket connection stats, async profiler stats, and so on). A shared tests/examples/conftest.py fixture (import_example) imports each example fresh per test and evicts it afterwards, since several examples build module-level toolbar/app singletons at import time. Add make test-examples to run just this suite.
Runs tests/examples against uv sync --all-extras --upgrade (ignoring the lockfile pins) on the oldest and newest supported Python versions, on a weekly schedule, workflow_dispatch, and PRs touching examples/ or tests/examples/. Prints resolved versions of the key frameworks for debugging. Not part of the required CI Success aggregator. Confirmed this actually catches regressions: with mcp upgraded past 2.0, debug_toolbar.mcp.server fails to import because mcp 2.x renamed FastMCP to MCPServer, which this workflow surfaces as a test failure in tests/examples/test_mcp_server_example.py.
…logic The standalone panel demo tests previously had a second test per script that reconstructed the same DebugToolbar/Panel/Config objects the script's main() builds, independent of the script itself. That let a broken script (e.g. a renamed import, wrong panel class, wrong config key) pass the test suite as long as the underlying panel class still worked when built directly. Replace those with a single test per script that imports the module and calls its real main() (or free functions, for cache_panel_demo), capturing real printed output and asserting on specific computed values (counts, ratios, byte totals, timings, redacted fields) that would change if the panel actually broke. Also widen examples-latest.yml's pull_request trigger to include src/** and pyproject.toml, since a library change (not just an examples/tests change) can break examples against upgraded dependencies.
PR #61 made the asgi_basic example inject the toolbar markup into HTML responses, serve /_debug_toolbar/static/{toolbar.css,toolbar.js}, and move its JSON endpoints to /_debug_toolbar/api/requests(/<id>). Flip the tests that previously asserted the pre-fix absence of these behaviors to assert the real, now-fixed behavior instead.
PR #64 made the FastAPI dependency injection panel actually populate resolved_dependencies for nested Depends() trees; assert on the real dependency names (get_db, get_current_user, get_token) and counts instead of only checking the panel key exists. PR #67 made the async profiler's taskfactory backend report the real caller-supplied task name (previously always 'Task-N') and made blocking call detection actually fire (previously silent, since asyncio logs slow callbacks via the asyncio logger rather than call_exception_handler). Assert on the real task names and a real detected blocking call instead of working around both bugs.
JacobCoffee
force-pushed
the
test/example-apps
branch
from
October 11, 2026 01:48
90626b4 to
0d9d47a
Compare
JacobCoffee
enabled auto-merge (squash)
October 11, 2026 01:48
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tests/examples/with 95 tests covering every app underexamples/:asgi_basic,litestar_basic,litestar_advanced_alchemy,starlette_basic,fastapi_basic,websocket_panel_example,graphql_panel_example,mcp_server_example, and the eight standalone panel demo scripts (cache, templates, settings, profiling, memory, flamegraph, async_profiler, alerts).tests/examples/conftest.pyimport_examplefixture that imports each example module fresh per test and evicts it afterwards, since several examples build module-level toolbar/app singletons (and some write real files like./example.dbor.debug_toolbar_storage.json) at import time.litestar_advanced_alchemy:DELETE /api/users/{id}500'd for any user with posts because theUser.postsrelationship had no cascade, andPost.author_idis non-nullable..github/workflows/examples-latest.yml("Examples (latest dependencies)"), which runstests/examplesagainstuv sync --all-extras --upgradeon Python 3.10 and 3.15, on a weekly schedule /workflow_dispatch/ PRs touchingexamples/. Not part of theCI Successaggregator.make test-examples.Verification
make cipasses (755 passed, 13 skipped).tests/examplespasses standalone (95 passed, ~20s) and interleaved with the rest of the suite with no cross-test interference.enabled=Falseonlitestar_basic's toolbar config and observed 10/12 of its tests fail (toolbar markup missing, static assets 404, history/detail endpoints 404); reverted cleanly.uv sync --all-extras --upgrade): litestar 2.24.0, starlette 1.7.0, fastapi 0.143.0, advanced-alchemy 1.11.0, sqlalchemy 2.1.4, strawberry-graphql 0.333.0, mcp 2.3.0. This genuinely caught a real regression:mcp>=2.0renamedFastMCPtoMCPServer, which breaksdebug_toolbar.mcp.server's import and fails the 2 MCP tool-registry tests. That's a library-level incompatibility insrc/debug_toolbar/mcp/server.py(not an example bug), out of scope for this examples-only PR, but it's exactly the kind of regression this new workflow is meant to surface going forward — flagging for a follow-up fix (e.g. pinmcp<2or support both APIs).Notes
examples/asgi_basiccurrently has no toolbar HTML injection, static asset routes, or/_debug_toolbar/api/requestspath (PR fix(examples): show the debug toolbar in the asgi_basic example #61, in flight) —test_asgi_basic.pytests its current behavior (absence of injection, 404 on static assets, its own hand-rolled JSON endpoints) rather than asserting the pending fix. Once fix(examples): show the debug toolbar in the asgi_basic example #61 lands,test_home_page_does_not_inject_toolbar_markup/test_static_assets_are_not_served_yetshould be flipped to positive assertions.mainand picked up by rebasing this branch).fix/fastapi-dependencies-panel, in flight) or the collapse-button aria fix (fix: update collapse button aria-label and aria-expanded on toggle #62) — out of scope.