From b605aa056e6381e959c8fb20546c9bc0d7dbacf1 Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Thu, 2 May 2024 17:21:27 -0500 Subject: [PATCH] Stop using make_temp_env (#13884) --- tests/core/test_subdir_data.py | 3 +-- tests/gateways/test_connection.py | 23 +++++++++++++---------- tests/test_create.py | 3 --- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/tests/core/test_subdir_data.py b/tests/core/test_subdir_data.py index c79152c3152..2aa208d59f9 100644 --- a/tests/core/test_subdir_data.py +++ b/tests/core/test_subdir_data.py @@ -24,7 +24,6 @@ from conda.models.channel import Channel from conda.models.records import PackageRecord from conda.testing.helpers import CHANNEL_DIR_V1, CHANNEL_DIR_V2 -from conda.testing.integration import make_temp_env from conda.utils import url_path log = getLogger(__name__) @@ -182,7 +181,7 @@ def __exit__(self, *exc): Channel._cache_.clear() # disable SSL_VERIFY to cover 'turn off warnings' line - with ChannelCacheClear(), make_temp_env(), env_vars( + with ChannelCacheClear(), env_vars( {"CONDA_PLATFORM": platform, "CONDA_SSL_VERIFY": "false"}, stack_callback=conda_tests_ctxt_mgmt_def_pol, ): diff --git a/tests/gateways/test_connection.py b/tests/gateways/test_connection.py index b367de53eb1..f2f804f30dd 100644 --- a/tests/gateways/test_connection.py +++ b/tests/gateways/test_connection.py @@ -1,8 +1,11 @@ # Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause +from __future__ import annotations + import hashlib from logging import getLogger from pathlib import Path +from typing import TYPE_CHECKING from unittest.mock import patch import pytest @@ -26,7 +29,9 @@ from conda.gateways.disk.delete import rm_rf from conda.plugins.types import ChannelAuthBase from conda.testing.gateways.fixtures import MINIO_EXE -from conda.testing.integration import make_temp_env + +if TYPE_CHECKING: + from conda.testing import TmpEnvFixture log = getLogger(__name__) @@ -80,18 +85,18 @@ def test_local_file_adapter_200(): @pytest.mark.skipif(MINIO_EXE is None, reason="Minio server not available") @pytest.mark.integration -def test_s3_server(minio_s3_server): +def test_s3_server(minio_s3_server, tmp_env: TmpEnvFixture): endpoint = minio_s3_server.endpoint bucket_name = minio_s3_server.name channel_dir = Path(__file__).parent.parent / "data" / "conda_format_repo" minio_s3_server.populate_bucket(endpoint, bucket_name, channel_dir) - inner_s3_test(endpoint, bucket_name) + inner_s3_test(tmp_env, endpoint, bucket_name) @pytest.mark.integration -def test_s3_server_with_mock(package_server): +def test_s3_server_with_mock(package_server, tmp_env: TmpEnvFixture): """ Use boto3 to fetch from a mock s3 server pointing at the test package repository. This works since conda only GET's against s3 and s3 is http. @@ -100,10 +105,10 @@ def test_s3_server_with_mock(package_server): endpoint_url = f"http://{host}:{port}" bucket_name = "test" - inner_s3_test(endpoint_url, bucket_name) + inner_s3_test(tmp_env, endpoint_url, bucket_name) -def inner_s3_test(endpoint_url, bucket_name): +def inner_s3_test(tmp_env: TmpEnvFixture, endpoint_url, bucket_name): """ Called by functions that build a populated s3 server. @@ -135,16 +140,14 @@ def inner_s3_test(endpoint_url, bucket_name): with env_vars( {"CONDA_USE_ONLY_TAR_BZ2": "True", "CONDA_SUBDIR": "linux-64"} ): - with make_temp_env( + with tmp_env( "--override-channels", f"--channel=s3://{bucket_name}", "--download-only", "--no-deps", # this fake repo only includes the zlib tarball "zlib", - use_exception_handler=False, - no_capture=True, ): - # we just want to run make_temp_env and cleanup after + # we just want to run tmp_env and cleanup after pass diff --git a/tests/test_create.py b/tests/test_create.py index 68ef3526a4e..d9343cb8aae 100644 --- a/tests/test_create.py +++ b/tests/test_create.py @@ -767,9 +767,6 @@ def test_strict_resolve_get_reduced_index(monkeypatch: MonkeyPatch): def test_list_with_pip_no_binary(tmp_env: TmpEnvFixture, conda_cli: CondaCLIFixture): from conda.exports import rm_rf as _rm_rf - # For this test to work on Windows, you can either pass use_restricted_unicode=on_win - # to make_temp_env(), or you can set PYTHONUTF8 to 1 (and use Python 3.7 or above). - # We elect to test the more complex of the two options. py_ver = "3.10" with tmp_env(f"python={py_ver}", "pip") as prefix: check_call(