Skip to content

Commit

Permalink
Improve test-coverage tests/helpers.py (python-poetry#9624)
Browse files Browse the repository at this point in the history
  • Loading branch information
dasschnee committed Aug 16, 2024
1 parent eb97d90 commit b499944
Showing 1 changed file with 23 additions and 0 deletions.
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

0 comments on commit b499944

Please sign in to comment.