Skip to content

Commit

Permalink
Stop using make_temp_env (conda#13884)
Browse files Browse the repository at this point in the history
  • Loading branch information
kenodegard authored May 2, 2024
1 parent e048f31 commit b605aa0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
3 changes: 1 addition & 2 deletions tests/core/test_subdir_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down Expand Up @@ -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,
):
Expand Down
23 changes: 13 additions & 10 deletions tests/gateways/test_connection.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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__)

Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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


Expand Down
3 changes: 0 additions & 3 deletions tests/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit b605aa0

Please sign in to comment.