Commit graph

27 commits

Author SHA1 Message Date
Simon Willison
1000d50220 datasette.fixtures module, closes #2733
https://gist.github.com/simonw/613be79094d491dd08f45e05f4f70691
2026-05-21 23:05:37 -07:00
Simon Willison
03eeeb9d92 Docs: auto-close plugin now handles function-scoped fixtures
Describe the updated scoping rule: instances from test bodies and
function-scoped fixtures are closed automatically; session-, module-,
class- and package-scoped fixtures are exempt.

Refs #2692
2026-04-16 20:38:08 -07:00
Simon Willison
34cc320eab Pytest auto-close plugin for Datasette instances
Installs a pytest11 entry point so that every Datasette() constructed
inside a pytest_runtest_call phase is auto-closed at the end of the test.
Fixture-scoped instances are untouched. Opt out via the
datasette_autoclose = false ini option.

This gives large test suites a safety net against FD exhaustion and leaked
write threads from the now-default temp-disk internal database without
requiring every existing test to be rewritten.

Refs #2692

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-16 20:15:50 -07:00
Simon Willison
0b639a8122
Replace token-based CSRF with Sec-Fetch-Site header protection (#2689)
- New CSRF protection middleware inspired by Go 1.25 and research by Filippo Valsorda - https://words.filippo.io/csrf/ - this replaces the old CSRF token based protection.
- Removes all instances of `<input type="hidden" name="csrftoken" value="{{ csrftoken() }}">` in the templates - they are no longer needed.
- Removes the `def skip_csrf(datasette, scope):` plugin hook defined in `datasette/hookspecs.py` and its documentation and tests.
- Updated CSRF protection documentation to describe the new approach.
- Upgrade guide now describes the CSRF change.
2026-04-14 17:11:36 -07:00
Simon Willison
6a2c27b15b blacken-docs 2026-02-20 11:28:39 -08:00
Simon Willison
4b4add4d31 datasette.pm property, closes #2595 2025-11-13 10:31:03 -08:00
Simon Willison
ce4b0794b2
Ported setup.py to pyproject.toml (#2555)
* Ported setup.py to pyproject.toml, refs #2553

* Make fixtures tests less flaky

The in-memory fixtures table was being shared between different
instances of the test client, leading to occasional errors when
running the full test suite.
2025-10-30 10:41:41 -07:00
Simon Willison
7a5adb592a Docs on temporary plugins in fixtures, closes #2234 2024-01-12 14:12:14 -08:00
Simon Willison
0f63cb83ed
Typo fix 2024-01-10 13:08:52 -08:00
Simon Willison
7506a89be0 Docs on datasette.client for tests, closes #1830
Also covers ds.client.actor_cookie() helper
2024-01-10 13:04:34 -08:00
Simon Willison
63fb750f39 Replace AsgiLifespan with AsgiRunOnFirstRequest, refs #1955 2022-12-17 14:14:34 -08:00
Simon Willison
0b68996cc5 Revert "Replace AsgiLifespan with AsgiRunOnFirstRequest, refs #1955"
This reverts commit dc18f62089.
2022-12-15 13:06:45 -08:00
Simon Willison
dc18f62089 Replace AsgiLifespan with AsgiRunOnFirstRequest, refs #1955 2022-12-15 09:34:07 -08:00
Simon Willison
ddc999ad12 Async support for prepare_jinja2_environment, closes #1809 2022-09-16 20:38:24 -07:00
Simon Willison
8cfc723368 Ran blacken-docs 2022-08-09 11:21:53 -07:00
Simon Willison
7af67b54b7 How to register temporary plugins in tests, closes #903 2022-07-18 14:31:17 -07:00
Simon Willison
a5acfff4bd
Empty Datasette([]) list is no longer required 2022-05-16 17:06:40 -07:00
Simon Willison
289e4cf80a Finished applying blacken-docs, closes #1718 2022-04-24 09:17:59 -07:00
Simon Willison
498e1536f5 One more blacken-docs test, refs #1718 2022-04-24 09:08:56 -07:00
Simon Willison
e73fa72917
Fixed bug in httpx_mock example, closes #1691 2022-03-26 15:46:08 -07:00
Simon Willison
42caabf7e9
Fixed typo 2021-02-22 09:35:41 -08:00
Simon Willison
beb98bf454
Fixed typo in code example 2021-01-31 00:49:09 -08:00
Simon Willison
dde3c500c7
Using pdb for errors thrown inside Datasette
Closes #1207
2021-01-28 18:12:32 -08:00
Simon Willison
f78e956eca Plugin testing documentation on using pytest-httpx
Closes #1198
2021-01-24 12:38:29 -08:00
Simon Willison
8df116b24c sqlite-utils now lives at sqlite-utils.datasette.io 2020-12-29 13:38:53 -08:00
Simon Willison
12877d7a48
Plugin testing docs now recommend datasette.client, closes #1102 2020-11-28 23:44:57 -08:00
Simon Willison
000528192e New 'Testing plugins' page, closes #687 2020-06-21 20:53:42 -07:00