mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 01:29:51 +08:00
22 lines
695 B
Python
22 lines
695 B
Python
from __future__ import annotations
|
|
|
|
from fastapi.testclient import TestClient
|
|
|
|
|
|
def test_unhandled_exception_returns_json_error() -> None:
|
|
from deeptutor.api.main import app
|
|
|
|
@app.get("/api/v1/__test_unhandled_exception__")
|
|
def _raise_unhandled() -> None:
|
|
raise RuntimeError("intentional test failure")
|
|
|
|
client = TestClient(app, raise_server_exceptions=False)
|
|
response = client.get("/api/v1/__test_unhandled_exception__")
|
|
|
|
assert response.status_code == 500
|
|
assert response.headers["content-type"].startswith("application/json")
|
|
assert response.json() == {
|
|
"detail": "RuntimeError: intentional test failure",
|
|
"type": "RuntimeError",
|
|
}
|