From 24bf79d2f01f373eafcb41eaa1279a13711eff25 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Sat, 11 May 2019 16:22:55 -0700 Subject: [PATCH] Run sanity checks, not .inspect(), on startup Also fixes tests that did NOT like a call to run_until_complete in the Datasette() constructor. --- datasette/app.py | 2 -- datasette/cli.py | 6 ++++-- tests/conftest.py | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/datasette/app.py b/datasette/app.py index 707f3b52..c2bf330f 100644 --- a/datasette/app.py +++ b/datasette/app.py @@ -344,8 +344,6 @@ class Datasette: except ValueError: # Plugin already registered pass - # Run the sanity checks - asyncio.get_event_loop().run_until_complete(self.run_sanity_checks()) async def run_sanity_checks(self): # Only one check right now, for Spatialite diff --git a/datasette/cli.py b/datasette/cli.py index 668ee1fd..c9d7d6d8 100644 --- a/datasette/cli.py +++ b/datasette/cli.py @@ -412,6 +412,8 @@ def serve( memory=memory, version_note=version_note, ) - # Force initial hashing/table counting - ds.inspect() + # Run async sanity checks - but only if we're not under pytest + asyncio.get_event_loop().run_until_complete(ds.run_sanity_checks()) + + # Start the server ds.app().run(host=host, port=port, debug=debug) diff --git a/tests/conftest.py b/tests/conftest.py index f9b84c4c..6cc1f044 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -15,6 +15,7 @@ def pytest_collection_modifyitems(items): move_to_front(items, "test_black") move_to_front(items, "test_inspect_cli") move_to_front(items, "test_inspect_cli_writes_to_file") + move_to_front(items, "test_spatialite_error_if_attempt_to_open_spatialite") def move_to_front(items, test_name):