Skip to content

Commit ec545b7

Browse files
committed
remove dunders
1 parent be26393 commit ec545b7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

instrumentation/opentelemetry-instrumentation-fastapi/tests/test_fastapi_instrumentation.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# pylint: disable=too-many-lines
1616

1717
import unittest
18+
from contextlib import ExitStack
1819
from timeit import default_timer
1920
from unittest.mock import Mock, patch
2021

@@ -173,10 +174,11 @@ def setUp(self):
173174
self._client = TestClient(self._app, base_url="https://testserver:443")
174175
# run the lifespan, initialize the middleware stack
175176
# this is more in-line with what happens in a real application when the server starts up
176-
self._client_teardown = self._client.__enter__() # pylint: disable=unnecessary-dunder-call
177+
self._exit_stack = ExitStack()
178+
self._exit_stack.enter_context(self._client)
177179

178180
def tearDown(self):
179-
self._client_teardown.__exit__(None, None, None) # pylint: disable=unnecessary-dunder-call
181+
self._exit_stack.close()
180182
super().tearDown()
181183
self.env_patch.stop()
182184
self.exclude_patch.stop()

0 commit comments

Comments
 (0)