Commit graph

10 commits

Author SHA1 Message Date
Alex Garcia
c748683f2e Apply ruff 0.16 and black fixes
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012U7coQfVu8nK2R4q2mCULA
2026-08-31 13:17:44 -07:00
Alex Garcia
d4b6d6cf4e Fix datasette-litestream URL and trim marker-task test comments
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012U7coQfVu8nK2R4q2mCULA
2026-08-31 13:13:03 -07:00
Alex Garcia
ba3756eb54 Move the serve-subprocess test plumbing into a conftest fixture
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>
2026-08-31 13:13:03 -07:00
Alex Garcia
cd9daa266c Run datasette serve startup and uvicorn on a single event loop
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-31 13:13:03 -07:00
Simon Willison
e889403d3b
Upgrade to ruff>=0.16.0 (#2857)
* ruff>=0.16.0

See https://astral.sh/blog/ruff-v0.16.0

* uv run ruff check . --fix --unsafe-fixes

* Ruff fixes by Claude Code Opus 5
2026-07-25 15:47:08 -07:00
Simon Willison
d1d369456a Move HTTPS test to a bash script
See https://github.com/simonw/datasette/issues/1955#issuecomment-1356627931
2022-12-17 18:33:07 -08:00
Simon Willison
de2a106328 Ran Black, refs #1388 2021-07-10 16:46:49 -07:00
Simon Willison
180c7a5328 --uds option for binding to Unix domain socket, closes #1388 2021-07-10 16:37:30 -07:00
Simon Willison
0a7621f96f
Use pytest-xdist to speed up tests (#1290)
* Run tests in CI using pytest-xdist
* Documentation for pytest-xdist

Closes #1289
2021-04-02 20:42:28 -07:00
Simon Willison
9603d893b9 Tests for --ssl-keyfile and --ssl-certfile, refs #1221 2021-02-11 16:53:20 -08:00