Replace AsgiLifespan with AsgiRunOnFirstRequest, refs #1955

This commit is contained in:
Simon Willison 2022-12-15 09:34:07 -08:00
commit 63fb750f39
4 changed files with 22 additions and 49 deletions

View file

@ -902,13 +902,14 @@ Potential use-cases:
.. note::
If you are writing :ref:`unit tests <testing_plugins>` for a plugin that uses this hook you will need to explicitly call ``await ds.invoke_startup()`` in your tests. An example:
If you are writing :ref:`unit tests <testing_plugins>` for a plugin that uses this hook and doesn't exercise Datasette by sending
any simulated requests through it you will need to explicitly call ``await ds.invoke_startup()`` in your tests. An example:
.. code-block:: python
@pytest.mark.asyncio
async def test_my_plugin():
ds = Datasette([], metadata={})
ds = Datasette()
await ds.invoke_startup()
# Rest of test goes here