Skip to content

Commit

Permalink
Use datasette_test.wait_until_responds
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Feb 29, 2024
1 parent 0a7e145 commit 7c94a16
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
9 changes: 8 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,14 @@ def get_long_description():
},
install_requires=["datasette>=0.54", "datasette-leaflet>=0.2.2"],
extras_require={
"test": ["pytest", "pytest-asyncio", "httpx", "sqlite-utils", "nest-asyncio"],
"test": [
"pytest",
"pytest-asyncio",
"httpx",
"sqlite-utils",
"nest-asyncio",
"datasette-test",
],
"playwright": ["pytest-playwright"],
},
)
12 changes: 1 addition & 11 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import datasette
from datasette_test import wait_until_responds
import pytest
import sqlite3
from subprocess import Popen, PIPE
Expand Down Expand Up @@ -54,14 +55,3 @@ def ds_server(tmp_path_factory):
yield "http://localhost:8126"
process.terminate()
process.wait()


def wait_until_responds(url, timeout=5.0):
start = time.time()
while time.time() - start < timeout:
try:
httpx.get(url)
return
except httpx.ConnectError:
time.sleep(0.1)
raise AssertionError("Timed out waiting for {} to respond".format(url))

0 comments on commit 7c94a16

Please sign in to comment.