mirror of
https://github.com/simonw/datasette.git
synced 2026-09-06 16:44:06 +02:00
The two new tests span a datasette serve subprocess by hand: each found a free port with a copy of test_playwright.py's find_free_port, built its own subprocess.Popen call, polled with its own 15 second deadline loop, and tore the process down in its own finally block. That is the third and fourth hand-rolled copy of plumbing conftest.py already owns for ds_localhost_http_server and ds_unix_domain_socket_server. Move find_free_port into conftest.py and add a serve_with_plugins factory fixture that writes plugin sources to a temporary --plugins-dir, takes a free port, waits for the server to answer, and terminates every process it started when the test ends. wait_until_responds() grows an optional process argument so a server that dies during startup fails immediately with its captured output instead of waiting out the timeout, and now catches httpx.TransportError rather than only httpx.ConnectError - a superclass, so existing callers are unaffected. Two fixes beyond the deduplication: The marker test polls until its flag flips, which meant it would also have passed if the startup hook were re-run on the serving loop by the first-request fallback - the exact bug it exists to catch. That cannot happen while invoke_startup() is idempotent, but nothing said so. The plugin now counts startup calls and the test asserts it ran exactly once, so removing that guard fails the test loudly instead of quietly turning it into a no-op. test_startup_error_fails_fast_before_port_binds passes on unmodified main, where startup already ran ahead of uvicorn.run(), so it is a characterization test rather than a regression test for this commit; its docstring now says so. Its loop re-checking that nothing was listening ran about one iteration before the process exited, and could not distinguish a pre-bind failure from a port nothing ever touched, so it is replaced by a single check with a comment about what it does and does not prove. Verified the red side is preserved: the marker test still fails on unmodified main, now in 3.7s rather than 15.2s. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| plugins | ||
| test_templates | ||
| __init__.py | ||
| build_small_spatialite_db.py | ||
| conftest.py | ||
| ext.c | ||
| fixtures.py | ||
| spatialite.db | ||
| test-datasette-load-plugins.sh | ||
| test_actions_sql.py | ||
| test_actor_restriction_bug.py | ||
| test_allowed_many.py | ||
| test_allowed_resources.py | ||
| test_api.py | ||
| test_api_write.py | ||
| test_auth.py | ||
| test_autocomplete.py | ||
| test_base_view.py | ||
| test_cli.py | ||
| test_cli_serve_get.py | ||
| test_cli_serve_server.py | ||
| test_column_types.py | ||
| test_config_dir.py | ||
| test_config_permission_rules.py | ||
| test_crossdb.py | ||
| test_csrf_middleware.py | ||
| test_csv.py | ||
| test_custom_pages.py | ||
| test_datasette_https_server.sh | ||
| test_debug_autocomplete.py | ||
| test_default_deny.py | ||
| test_docs.py | ||
| test_docs_plugins.py | ||
| test_error_shape.py | ||
| test_extras.py | ||
| test_facets.py | ||
| test_fd_leak.py | ||
| test_filters.py | ||
| test_fixtures.py | ||
| test_html.py | ||
| test_internal_db.py | ||
| test_internals_database.py | ||
| test_internals_datasette.py | ||
| test_internals_datasette_client.py | ||
| test_internals_request.py | ||
| test_internals_response.py | ||
| test_internals_urls.py | ||
| test_jump.py | ||
| test_label_column_for_table.py | ||
| test_load_extensions.py | ||
| test_messages.py | ||
| test_multipart.py | ||
| test_package.py | ||
| test_permission_endpoints.py | ||
| test_permissions.py | ||
| test_playwright.py | ||
| test_plugins.py | ||
| test_publish_cloudrun.py | ||
| test_publish_heroku.py | ||
| test_pytest_autoclose_plugin.py | ||
| test_queries.py | ||
| test_restriction_sql.py | ||
| test_routes.py | ||
| test_schema_endpoints.py | ||
| test_search_tables.py | ||
| test_spatialite.py | ||
| test_stored_queries.py | ||
| test_success_envelope.py | ||
| test_table_api.py | ||
| test_table_html.py | ||
| test_template_context.py | ||
| test_token_handler.py | ||
| test_tracer.py | ||
| test_utils.py | ||
| test_utils_check_callable.py | ||
| test_utils_permissions.py | ||
| test_utils_sql_analysis.py | ||
| test_write_sql_operation_decisions.py | ||
| test_write_wrapper.py | ||
| utils.py | ||