From 08a7fcf1cd8285683c47140b36b3d181e9448273 Mon Sep 17 00:00:00 2001 From: Jeremy Fleischman Date: Fri, 7 Jan 2022 00:12:15 -0800 Subject: [PATCH] Oops, set the `CI` environment variable even earlier. If I do something like `pytest tests/integration/test_cli.py`, something about the ordering of imports means that `pipenv.environments` gets loaded *before* `pytest_sessionstart` runs, which means that `pipenv.environments.PIPENV_IS_CI` ends up false. --- tests/conftest.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index a07377194a..13778403e4 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,9 +1,14 @@ import pytest import os +# Note that we have to do this *before* `pipenv.environments` gets imported, +# which is why we're doing it here as a side effect of importing this module. +# CI=1 is necessary as a workaround for https://github.com/pypa/pipenv/issues/4909 +os.environ['CI'] = '1' + def pytest_sessionstart(session): - # CI=1 is necessary as a workaround for https://github.com/pypa/pipenv/issues/4909 - os.environ['CI'] = '1' + import pipenv.environments + assert pipenv.environments.PIPENV_IS_CI @pytest.fixture()