mirror of https://github.com/tiangolo/fastapi.git
assert that include_router does not cause initialization
This commit is contained in:
parent
50f61eca50
commit
424a512a3a
|
|
@ -1,3 +1,4 @@
|
|||
from itertools import chain
|
||||
from typing import List, Optional
|
||||
|
||||
from fastapi import APIRouter, Depends, FastAPI
|
||||
|
|
@ -104,3 +105,13 @@ def test_root_router_always_initialized():
|
|||
client = TestClient(app)
|
||||
response = client.get("/test")
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
def test_include_router_no_init():
|
||||
router1 = create_test_router()
|
||||
|
||||
router2 = create_test_router()
|
||||
router2.include_router(router1)
|
||||
|
||||
for route in chain(router1.routes, router2.routes):
|
||||
check_if_initialized(route, should_not=True)
|
||||
|
|
|
|||
Loading…
Reference in New Issue