@@ -129,9 +129,38 @@ def ensure_py_info_cache_empty(session_app_data):
129
129
PythonInfo .clear_cache (session_app_data )
130
130
131
131
132
- @pytest .fixture (autouse = True )
133
- def ignore_global_config (tmp_path , monkeypatch ):
134
- monkeypatch .setenv (ensure_str ("VIRTUALENV_CONFIG_FILE" ), str (tmp_path / "this-should-never-exist" ))
132
+ @contextmanager
133
+ def change_os_environ (key , value ):
134
+ env_var = key
135
+ previous = os .environ [env_var ] if env_var in os .environ else None
136
+ os .environ [env_var ] = value
137
+ try :
138
+ yield
139
+ finally :
140
+ if previous is not None :
141
+ os .environ [env_var ] = previous
142
+
143
+
144
+ @pytest .fixture (autouse = True , scope = "session" )
145
+ def ignore_global_config (tmp_path_factory ):
146
+ filename = str (tmp_path_factory .mktemp ("folder" ) / "virtualenv-test-suite.ini" )
147
+ with change_os_environ (ensure_str ("VIRTUALENV_CONFIG_FILE" ), filename ):
148
+ yield
149
+
150
+
151
+ @pytest .fixture (autouse = True , scope = "session" )
152
+ def pip_cert (tmp_path_factory ):
153
+ # workaround for https://github.com/pypa/pip/issues/8984 - if the certificate is explicitly set no error can happen
154
+ key = ensure_str ("PIP_CERT" )
155
+ if key in os .environ :
156
+ return
157
+ cert = tmp_path_factory .mktemp ("folder" ) / "cert"
158
+ import pkgutil
159
+
160
+ cert_data = pkgutil .get_data ("pip._vendor.certifi" , "cacert.pem" )
161
+ cert .write_bytes (cert_data )
162
+ with change_os_environ (key , str (cert )):
163
+ yield
135
164
136
165
137
166
@pytest .fixture (autouse = True )
0 commit comments