1010import pip
1111import pytest
1212from aiohttp import web
13- from aiohttp .test_utils import TestClient
1413from opentelemetry import trace
1514from opentelemetry .sdk .trace .export .in_memory_span_exporter import InMemorySpanExporter
1615from pydantic import ValidationError
@@ -59,10 +58,10 @@ async def test_valid_tracing_settings(
5958 set_and_clean_settings_env_vars : Callable ,
6059 tracing_settings_in ,
6160 uninstrument_opentelemetry : Iterator [None ],
62- ) -> TestClient :
61+ ):
6362 app = web .Application ()
6463 service_name = "simcore_service_webserver"
65- tracing_settings = TracingSettings ()
64+ tracing_settings = TracingSettings . create_from_envs ()
6665 async for _ in get_tracing_lifespan (
6766 app = app , service_name = service_name , tracing_settings = tracing_settings
6867 )(app ):
@@ -83,9 +82,9 @@ async def test_invalid_tracing_settings(
8382 set_and_clean_settings_env_vars : Callable ,
8483 tracing_settings_in ,
8584 uninstrument_opentelemetry : Iterator [None ],
86- ) -> TestClient :
85+ ):
8786 with pytest .raises (ValidationError ):
88- TracingSettings ()
87+ TracingSettings . create_from_envs ()
8988
9089
9190def install_package (package ):
@@ -96,7 +95,7 @@ def uninstall_package(package):
9695 pip .main (["uninstall" , "-y" , package ])
9796
9897
99- @pytest .fixture ( scope = "function" )
98+ @pytest .fixture
10099def manage_package (request ):
101100 package , importname = request .param
102101 install_package (package )
@@ -139,7 +138,7 @@ async def test_tracing_setup_package_detection(
139138 #
140139 app = web .Application ()
141140 service_name = "simcore_service_webserver"
142- tracing_settings = TracingSettings ()
141+ tracing_settings = TracingSettings . create_from_envs ()
143142 async for _ in get_tracing_lifespan (
144143 app = app ,
145144 service_name = service_name ,
@@ -174,7 +173,7 @@ async def test_trace_id_in_response_header(
174173) -> None :
175174 app = web .Application ()
176175 service_name = "simcore_service_webserver"
177- tracing_settings = TracingSettings ()
176+ tracing_settings = TracingSettings . create_from_envs ()
178177
179178 async def handler (handler_data : dict , request : web .Request ) -> web .Response :
180179 current_span = trace .get_current_span ()
@@ -185,7 +184,7 @@ async def handler(handler_data: dict, request: web.Request) -> web.Response:
185184 raise server_response
186185 return server_response
187186
188- handler_data = dict ()
187+ handler_data = {}
189188 app .router .add_get ("/" , partial (handler , handler_data ))
190189
191190 async for _ in get_tracing_lifespan (
0 commit comments