Skip to content

Commit

Permalink
Unset env vars after reading to prevent persistent env vars from affe…
Browse files Browse the repository at this point in the history
…cting some tests
  • Loading branch information
abhahn committed Jun 28, 2024
1 parent c6b04f1 commit 2de5141
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tests/integration_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ def dotenv_template_params_from_kv(secret_client: SecretClient) -> dict[str, str

@pytest.fixture(scope="module")
def dotenv_template_params_from_env() -> dict[str, str]:
def get_and_unset_variable(var_name):
# we need this function to ensure that the environment is clean before
# testing with generated dotenv files.
var_value = os.getenv(var_name)
os.environ[var_name] = ""
return var_value

env_secrets = [
"AZURE_COSMOSDB_ACCOUNT",
"AZURE_COSMOSDB_ACCOUNT_KEY",
Expand All @@ -48,5 +55,5 @@ def dotenv_template_params_from_env() -> dict[str, str]:
"ELASTICSEARCH_QUERY"
]

return {s: os.getenv(s) for s in env_secrets}
return {s: get_and_unset_variable(s) for s in env_secrets}

0 comments on commit 2de5141

Please sign in to comment.