summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBernát Gábor <bgabor8@bloomberg.net>2020-12-21 17:19:31 +0000
committerGitHub <noreply@github.com>2020-12-21 17:19:31 +0000
commitbc787b2da64ab3dbe5bb9c5966ff411dc8a41705 (patch)
tree7583278df1f2b3594bba23ea2c4ec93600a31f84 /tests
parent838bfbc420277e823d6ce7f881773132933eecad (diff)
downloadvirtualenv-bc787b2da64ab3dbe5bb9c5966ff411dc8a41705.tar.gz
Try to fix the CI (#2041)
Diffstat (limited to 'tests')
-rw-r--r--tests/conftest.py35
1 files changed, 32 insertions, 3 deletions
diff --git a/tests/conftest.py b/tests/conftest.py
index 5fab330..b2317fc 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -129,9 +129,38 @@ def ensure_py_info_cache_empty(session_app_data):
PythonInfo.clear_cache(session_app_data)
-@pytest.fixture(autouse=True)
-def ignore_global_config(tmp_path, monkeypatch):
- monkeypatch.setenv(ensure_str("VIRTUALENV_CONFIG_FILE"), str(tmp_path / "this-should-never-exist"))
+@contextmanager
+def change_os_environ(key, value):
+ env_var = key
+ previous = os.environ[env_var] if env_var in os.environ else None
+ os.environ[env_var] = value
+ try:
+ yield
+ finally:
+ if previous is not None:
+ os.environ[env_var] = previous
+
+
+@pytest.fixture(autouse=True, scope="session")
+def ignore_global_config(tmp_path_factory):
+ filename = str(tmp_path_factory.mktemp("folder") / "virtualenv-test-suite.ini")
+ with change_os_environ(ensure_str("VIRTUALENV_CONFIG_FILE"), filename):
+ yield
+
+
+@pytest.fixture(autouse=True, scope="session")
+def pip_cert(tmp_path_factory):
+ # workaround for https://github.com/pypa/pip/issues/8984 - if the certificate is explicitly set no error can happen
+ key = ensure_str("PIP_CERT")
+ if key in os.environ:
+ return
+ cert = tmp_path_factory.mktemp("folder") / "cert"
+ import pkgutil
+
+ cert_data = pkgutil.get_data("pip._vendor.certifi", "cacert.pem")
+ cert.write_bytes(cert_data)
+ with change_os_environ(key, str(cert)):
+ yield
@pytest.fixture(autouse=True)