Skip to content

Commit 72fa339

Browse files
committed
ensure to delete env
1 parent d762da5 commit 72fa339

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

packages/service-library/tests/aiohttp/test_tracing.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,22 @@ def tracing_settings_in(request):
2424
def set_and_clean_settings_env_vars(
2525
monkeypatch: pytest.MonkeyPatch, tracing_settings_in
2626
):
27-
added_endpoint = False
27+
endpoint_mocked = False
2828
if tracing_settings_in[0]:
29-
added_endpoint = True
29+
endpoint_mocked = True
3030
monkeypatch.setenv(
3131
"TRACING_OPENTELEMETRY_COLLECTOR_ENDPOINT", f"{tracing_settings_in[0]}"
3232
)
33-
added_port = False
33+
port_mocked = False
3434
if tracing_settings_in[1]:
35-
added_port = True
35+
port_mocked = True
3636
monkeypatch.setenv(
3737
"TRACING_OPENTELEMETRY_COLLECTOR_PORT", f"{tracing_settings_in[1]}"
3838
)
3939
yield
40-
if added_endpoint:
40+
if endpoint_mocked:
4141
monkeypatch.delenv("TRACING_OPENTELEMETRY_COLLECTOR_ENDPOINT")
42-
if added_port:
42+
if port_mocked:
4343
monkeypatch.delenv("TRACING_OPENTELEMETRY_COLLECTOR_PORT")
4444

4545

packages/service-library/tests/fastapi/test_tracing.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,23 @@ def tracing_settings_in(request: pytest.FixtureRequest) -> dict[str, Any]:
2929
def set_and_clean_settings_env_vars(
3030
monkeypatch: pytest.MonkeyPatch, tracing_settings_in: Callable[[], dict[str, Any]]
3131
) -> None:
32+
endpoint_mocked = False
3233
if tracing_settings_in[0]:
34+
endpoint_mocked = True
3335
monkeypatch.setenv(
3436
"TRACING_OPENTELEMETRY_COLLECTOR_ENDPOINT", f"{tracing_settings_in[0]}"
3537
)
38+
port_mocked = False
3639
if tracing_settings_in[1]:
40+
port_mocked = True
3741
monkeypatch.setenv(
3842
"TRACING_OPENTELEMETRY_COLLECTOR_PORT", f"{tracing_settings_in[1]}"
3943
)
44+
yield
45+
if endpoint_mocked:
46+
monkeypatch.delenv("TRACING_OPENTELEMETRY_COLLECTOR_ENDPOINT")
47+
if port_mocked:
48+
monkeypatch.delenv("TRACING_OPENTELEMETRY_COLLECTOR_PORT")
4049

4150

4251
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)