We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5f61cb4 commit 0fe8c12Copy full SHA for 0fe8c12
backend/app/__init__.py
backend/tests/test_openapi_lifespan.py
@@ -0,0 +1,24 @@
1
+import pytest
2
+from fastapi import FastAPI
3
+from main import generate_openapi_json
4
+
5
6
+def test_openapi_failure_does_not_crash_app(monkeypatch):
7
+ def broken_openapi(*args, **kwargs):
8
+ raise Exception("Simulated failure")
9
10
+ monkeypatch.setattr(
11
+ "main.get_openapi",
12
+ broken_openapi
13
+ )
14
15
+ app = FastAPI()
16
17
+ try:
18
+ generate_openapi_json()
19
+ started = True
20
+ except Exception:
21
+ started = False
22
23
+ assert started, "App should not crash if OpenAPI generation fails"
24
0 commit comments