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

Function remove_ci_env_var

testing/conftest.py:243–251  ·  view source on GitHub ↗

Make the test insensitive if it is running in CI or not. Use `@pytest.mark.keep_ci_var` in a test to avoid applying this fixture, letting the test see the real `CI` variable (if present).

(monkeypatch: MonkeyPatch, request: pytest.FixtureRequest)

Source from the content-addressed store, hash-verified

241
242@pytest.fixture(autouse=True)
243def remove_ci_env_var(monkeypatch: MonkeyPatch, request: pytest.FixtureRequest) -> None:
244 """Make the test insensitive if it is running in CI or not.
245
246 Use `@pytest.mark.keep_ci_var` in a test to avoid applying this fixture, letting the test
247 see the real `CI` variable (if present).
248 """
249 has_keep_ci_mark = request.node.get_closest_marker("keep_ci_var") is not None
250 if not has_keep_ci_mark:
251 monkeypatch.delenv("CI", raising=False)

Callers

nothing calls this directly

Calls 2

get_closest_markerMethod · 0.80
delenvMethod · 0.80

Tested by

no test coverage detected