@@ -99,7 +99,9 @@ def index():
9999
100100
101101@pytest .fixture (
102- params = [False , True ], ids = ["no_api_transformer" , "mount_api_transformer" ]
102+ scope = "session" ,
103+ params = [False , True ],
104+ ids = ["no_api_transformer" , "mount_api_transformer" ],
103105)
104106def mount_api_transformer (request : pytest .FixtureRequest ) -> bool :
105107 """Whether to use api_transformer in the app.
@@ -113,7 +115,9 @@ def mount_api_transformer(request: pytest.FixtureRequest) -> bool:
113115 return request .param
114116
115117
116- @pytest .fixture (params = [False , True ], ids = ["no_fastapi" , "mount_cached_fastapi" ])
118+ @pytest .fixture (
119+ scope = "session" , params = [False , True ], ids = ["no_fastapi" , "mount_cached_fastapi" ]
120+ )
117121def mount_cached_fastapi (request : pytest .FixtureRequest ) -> bool :
118122 """Whether to use cached FastAPI in the app (app.api).
119123
@@ -126,22 +130,26 @@ def mount_cached_fastapi(request: pytest.FixtureRequest) -> bool:
126130 return request .param
127131
128132
129- @pytest .fixture
133+ @pytest .fixture ( scope = "session" )
130134def lifespan_app (
131- tmp_path , mount_api_transformer : bool , mount_cached_fastapi : bool
135+ tmp_path_factory : pytest .TempPathFactory ,
136+ app_harness_env : type [AppHarness ],
137+ mount_api_transformer : bool ,
138+ mount_cached_fastapi : bool ,
132139) -> Generator [AppHarness , None , None ]:
133140 """Start LifespanApp app at tmp_path via AppHarness.
134141
135142 Args:
136- tmp_path: pytest tmp_path fixture
143+ tmp_path_factory: pytest tmp_path_factory fixture
144+ app_harness_env: AppHarness environment
137145 mount_api_transformer: Whether to mount the API transformer.
138146 mount_cached_fastapi: Whether to mount the cached FastAPI app.
139147
140148 Yields:
141149 running AppHarness instance
142150 """
143- with AppHarness .create (
144- root = tmp_path ,
151+ with app_harness_env .create (
152+ root = tmp_path_factory . mktemp ( "lifespan_app" ) ,
145153 app_source = functools .partial (
146154 LifespanApp ,
147155 mount_cached_fastapi = mount_cached_fastapi ,
0 commit comments