MCPcopy
hub / github.com/pytest-dev/pytest / test_setenv_deleted_meanwhile

Function test_setenv_deleted_meanwhile

testing/test_monkeypatch.py:166–178  ·  view source on GitHub ↗
(before: bool)

Source from the content-addressed store, hash-verified

164
165@pytest.mark.parametrize("before", [True, False])
166def test_setenv_deleted_meanwhile(before: bool) -> None:
167 key = "qwpeoip123"
168 if before:
169 os.environ[key] = "world"
170 monkeypatch = MonkeyPatch()
171 monkeypatch.setenv(key, "hello")
172 del os.environ[key]
173 monkeypatch.undo()
174 if before:
175 assert os.environ[key] == "world"
176 del os.environ[key]
177 else:
178 assert key not in os.environ
179
180
181def test_delitem() -> None:

Callers

nothing calls this directly

Calls 3

setenvMethod · 0.95
undoMethod · 0.95
MonkeyPatchClass · 0.90

Tested by

no test coverage detected