Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve test-coverage tests/helpers.py #9624

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions tests/test_helpers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from __future__ import annotations

import os

from tests.helpers import flatten_dict
from tests.helpers import isolated_environment


def test_flatten_dict() -> None:
Expand All @@ -21,3 +24,23 @@ def test_flatten_dict() -> None:
}

assert flattened_dict == flatten_dict(orig_dict, delimiter=":")


def test_isolated_environment_restores_original_environ() -> None:
original_environ = dict(os.environ)
with isolated_environment():
os.environ["TEST_VAR"] = "test"
assert os.environ == original_environ


def test_isolated_environment_clears_environ() -> None:
os.environ["TEST_VAR"] = "test"
with isolated_environment(clear=True):
assert "TEST_VAR" not in os.environ
assert "TEST_VAR" in os.environ


def test_isolated_environment_updates_environ() -> None:
with isolated_environment(environ={"NEW_VAR": "new_value"}):
assert os.environ["NEW_VAR"] == "new_value"
assert "NEW_VAR" not in os.environ
Loading