Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/test-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
tests:
name: "Python ${{ matrix.python-version }}"
runs-on: "ubuntu-latest"
timeout-minutes: 15

strategy:
matrix:
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ check_untyped_defs = true

[tool.pytest.ini_options]
addopts = "-rxXs"
faulthandler_timeout = 60
filterwarnings = [
"error",
# Until https://github.com/encode/httpcore/pull/1119 fixes https://github.com/encode/httpx/issues/3597.
Expand Down
17 changes: 15 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,15 +269,28 @@ async def watch_restarts(self) -> None: # pragma: no cover


def serve_in_thread(server: TestServer) -> typing.Iterator[TestServer]:
thread = threading.Thread(target=server.run)
thread = threading.Thread(target=server.run, daemon=True)
startup_deadline = time.monotonic() + 10
thread.start()
try:
while not server.started:
if not thread.is_alive():
raise RuntimeError( # pragma: no cover
"Uvicorn test server exited before startup."
)
if time.monotonic() > startup_deadline:
raise TimeoutError( # pragma: no cover
"Uvicorn test server did not start within 10 seconds."
)
time.sleep(1e-3)
yield server
finally:
server.should_exit = True
thread.join()
thread.join(timeout=5)
if thread.is_alive():
raise TimeoutError( # pragma: no cover
"Uvicorn test server did not stop within 5 seconds."
)


@pytest.fixture(scope="session")
Expand Down
Loading