Skip to content

Commit 79d3790

Browse files
committed
test: Refactor environment variable reset
Signed-off-by: Ferenc Géczi <[email protected]>
1 parent 9f17f3d commit 79d3790

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

tests/platforms/test_host_collector.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,15 @@ def setUp(self):
2828

2929
def tearDown(self):
3030
""" Reset all environment variables of consequence """
31-
if "AWS_EXECUTION_ENV" in os.environ:
32-
os.environ.pop("AWS_EXECUTION_ENV")
33-
if "INSTANA_EXTRA_HTTP_HEADERS" in os.environ:
34-
os.environ.pop("INSTANA_EXTRA_HTTP_HEADERS")
35-
if "INSTANA_ENDPOINT_URL" in os.environ:
36-
os.environ.pop("INSTANA_ENDPOINT_URL")
37-
if "INSTANA_AGENT_KEY" in os.environ:
38-
os.environ.pop("INSTANA_AGENT_KEY")
39-
if "INSTANA_ZONE" in os.environ:
40-
os.environ.pop("INSTANA_ZONE")
41-
if "INSTANA_TAGS" in os.environ:
42-
os.environ.pop("INSTANA_TAGS")
43-
if "INSTANA_DISABLE_METRICS_COLLECTION" in os.environ:
44-
os.environ.pop("INSTANA_DISABLE_METRICS_COLLECTION")
31+
variable_names = (
32+
"AWS_EXECUTION_ENV", "INSTANA_EXTRA_HTTP_HEADERS",
33+
"INSTANA_ENDPOINT_URL", "INSTANA_AGENT_KEY", "INSTANA_ZONE",
34+
"INSTANA_TAGS", "INSTANA_DISABLE_METRICS_COLLECTION",
35+
)
36+
37+
for variable_name in variable_names:
38+
if variable_name in os.environ:
39+
os.environ.pop(variable_name)
4540

4641
set_agent(self.original_agent)
4742
set_tracer(self.original_tracer)

0 commit comments

Comments
 (0)