Skip to content

Commit c7a2fa2

Browse files
committed
test: Refactor environment variable reset for host tests
Signed-off-by: Ferenc Géczi <[email protected]>
1 parent b6cf663 commit c7a2fa2

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

tests/platforms/test_host.py

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,16 @@ def setUp(self):
2929

3030
def tearDown(self):
3131
""" Reset all environment variables of consequence """
32-
if "AWS_EXECUTION_ENV" in os.environ:
33-
os.environ.pop("AWS_EXECUTION_ENV")
34-
if "INSTANA_EXTRA_HTTP_HEADERS" in os.environ:
35-
os.environ.pop("INSTANA_EXTRA_HTTP_HEADERS")
36-
if "INSTANA_ENDPOINT_URL" in os.environ:
37-
os.environ.pop("INSTANA_ENDPOINT_URL")
38-
if "INSTANA_ENDPOINT_PROXY" in os.environ:
39-
os.environ.pop("INSTANA_ENDPOINT_PROXY")
40-
if "INSTANA_AGENT_KEY" in os.environ:
41-
os.environ.pop("INSTANA_AGENT_KEY")
42-
if "INSTANA_LOG_LEVEL" in os.environ:
43-
os.environ.pop("INSTANA_LOG_LEVEL")
44-
if "INSTANA_SERVICE_NAME" in os.environ:
45-
os.environ.pop("INSTANA_SERVICE_NAME")
46-
if "INSTANA_SECRETS" in os.environ:
47-
os.environ.pop("INSTANA_SECRETS")
48-
if "INSTANA_TAGS" in os.environ:
49-
os.environ.pop("INSTANA_TAGS")
32+
variable_names = (
33+
"AWS_EXECUTION_ENV", "INSTANA_EXTRA_HTTP_HEADERS",
34+
"INSTANA_ENDPOINT_URL", "INSTANA_ENDPOINT_PROXY",
35+
"INSTANA_AGENT_KEY", "INSTANA_LOG_LEVEL",
36+
"INSTANA_SERVICE_NAME", "INSTANA_SECRETS", "INSTANA_TAGS",
37+
)
38+
39+
for variable_name in variable_names:
40+
if variable_name in os.environ:
41+
os.environ.pop(variable_name)
5042

5143
set_agent(self.original_agent)
5244
set_tracer(self.original_tracer)

0 commit comments

Comments
 (0)