Skip to content

Commit fb1b65d

Browse files
committed
fix tests
Signed-off-by: emdneto <[email protected]>
1 parent 844f149 commit fb1b65d

File tree

2 files changed

+10
-6016
lines changed

2 files changed

+10
-6016
lines changed

instrumentation/opentelemetry-instrumentation-starlette/tests/test_starlette_instrumentation.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
from starlette import applications
2020
from starlette.responses import PlainTextResponse
21-
from starlette.routing import Mount, Route, WebSocketRoute
21+
from starlette.routing import Mount, Route
2222
from starlette.testclient import TestClient
2323
from starlette.websockets import WebSocket
2424

@@ -621,7 +621,10 @@ def tearDown(self) -> None:
621621

622622
@staticmethod
623623
def create_starlette_app():
624-
def foobar(request):
624+
app = applications.Starlette()
625+
626+
@app.route("/foobar")
627+
def _(request):
625628
return PlainTextResponse(
626629
content="hi",
627630
headers={
@@ -633,7 +636,8 @@ def foobar(request):
633636
},
634637
)
635638

636-
async def foobar_web(websocket: WebSocket) -> None:
639+
@app.websocket_route("/foobar_web")
640+
async def _(websocket: WebSocket) -> None:
637641
message = await websocket.receive()
638642
if message.get("type") == "websocket.connect":
639643
await websocket.send(
@@ -659,17 +663,11 @@ async def foobar_web(websocket: WebSocket) -> None:
659663
if message.get("type") == "websocket.disconnect":
660664
pass
661665

662-
return applications.Starlette(
663-
routes=[
664-
Route("/foobar", foobar),
665-
WebSocketRoute("/foobar_web", foobar_web),
666-
]
667-
)
666+
return app
668667

669668

670669
class TestHTTPAppWithCustomHeaders(TestBaseWithCustomHeaders):
671670
def setUp(self):
672-
super().setUp()
673671
self.test_env_patch = patch.dict(
674672
"os.environ",
675673
{
@@ -679,6 +677,7 @@ def setUp(self):
679677
},
680678
)
681679
self.test_env_patch.start()
680+
super().setUp()
682681

683682
def tearDown(self):
684683
self.test_env_patch.stop()
@@ -812,8 +811,8 @@ def setUp(self):
812811
super().setUp()
813812

814813
def tearDown(self):
815-
super().tearDown()
816814
self.test_env_patch.stop()
815+
super().tearDown()
817816

818817
def test_custom_request_headers_in_span_attributes(self):
819818
expected = {

0 commit comments

Comments
 (0)