Skip to content

Commit aa7acb0

Browse files
committed
Fix test_multiple_decorators unit test for FastAPI 0.118.0
Fix the following error in test_galaxy_packages: FAILED tests/webapps/api/test_cbv.py::test_multiple_decorators - AssertionError: fastapi_middleware_astack not found in request scope xref. fastapi/fastapi#14128
1 parent 2edc335 commit aa7acb0

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

test/unit/webapps/api/test_cbv.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,14 @@ def get_item(self) -> int: # Alphabetically before `get_test`
7070

7171
app = FastAPI()
7272
app.include_router(router)
73+
client = TestClient(app)
7374

74-
assert TestClient(app).get("/test").json() == 1
75-
assert TestClient(app).get("/other").json() == 2
75+
assert client.get("/test").json() == 1
76+
assert client.get("/other").json() == 2
7677

7778

7879
def test_multiple_decorators() -> None:
80+
app = FastAPI()
7981
router = APIRouter()
8082

8183
@cbv(router)
@@ -90,7 +92,9 @@ def root(self, item_path: Optional[str] = None, item_query: Optional[str] = None
9092
return {"item_query": item_query}
9193
return []
9294

93-
client = TestClient(router)
95+
app = FastAPI()
96+
app.include_router(router)
97+
client = TestClient(app)
9498

9599
assert client.get("/items").json() == []
96100
assert client.get("/items/1").json() == {"item_path": "1"}

0 commit comments

Comments
 (0)