2024-01-12 14:12:14 -08:00
|
|
|
# fmt: off
|
|
|
|
|
# -- start datasette_with_plugin_fixture --
|
|
|
|
|
from datasette import hookimpl
|
|
|
|
|
from datasette.app import Datasette
|
|
|
|
|
import pytest
|
|
|
|
|
import pytest_asyncio
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest_asyncio.fixture
|
|
|
|
|
async def datasette_with_plugin():
|
|
|
|
|
class TestPlugin:
|
|
|
|
|
__name__ = "TestPlugin"
|
|
|
|
|
|
|
|
|
|
@hookimpl
|
|
|
|
|
def register_routes(self):
|
|
|
|
|
return [
|
|
|
|
|
(r"^/error$", lambda: 1 / 0),
|
|
|
|
|
]
|
|
|
|
|
|
2025-11-13 10:31:03 -08:00
|
|
|
datasette = Datasette()
|
|
|
|
|
datasette.pm.register(TestPlugin(), name="undo")
|
2024-01-12 14:12:14 -08:00
|
|
|
try:
|
2025-11-13 10:31:03 -08:00
|
|
|
yield datasette
|
2024-01-12 14:12:14 -08:00
|
|
|
finally:
|
2025-11-13 10:31:03 -08:00
|
|
|
datasette.pm.unregister(name="undo")
|
2026-04-16 20:25:58 -07:00
|
|
|
datasette.close()
|
2024-01-12 14:12:14 -08:00
|
|
|
# -- end datasette_with_plugin_fixture --
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# -- start datasette_with_plugin_test --
|
|
|
|
|
@pytest.mark.asyncio
|
|
|
|
|
async def test_error(datasette_with_plugin):
|
|
|
|
|
response = await datasette_with_plugin.client.get("/error")
|
|
|
|
|
assert response.status_code == 500
|
|
|
|
|
# -- end datasette_with_plugin_test --
|