Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate testing_env fixture #5427

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions news/5427-deprecate-testing_env
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### Enhancements

* <news item>

### Bug fixes

* <news item>

### Deprecations

* Deprecate `tests.conftest.testing_env` fixture. Use `conda.testing.tmp_env` instead. (#5427)

### Docs

* <news item>

### Other

* <news item>
48 changes: 28 additions & 20 deletions tests/cli/test_main_develop.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,38 @@
# Copyright (C) 2014 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
import os
from __future__ import annotations

import sys
from pathlib import Path
from typing import TYPE_CHECKING

from conda.gateways.connection.download import download

from conda_build.cli import main_develop
from conda_build.utils import get_site_packages, tar_xf

if TYPE_CHECKING:
from conda.testing import TmpEnvFixture


def test_develop(tmp_env: TmpEnvFixture) -> None:
py_ver = "%d.%d" % sys.version_info[:2]
with tmp_env(f"python={py_ver}") as prefix:
download(
"https://pypi.io/packages/source/c/conda_version_test/conda_version_test-0.1.0-1.tar.gz",
"conda_version_test.tar.gz",
)
tar_xf("conda_version_test.tar.gz", prefix)
extract_folder = "conda_version_test-0.1.0-1"

main_develop.execute([f"--prefix={prefix}", extract_folder])
assert (
str(Path.cwd())
in Path(get_site_packages(prefix, py_ver), "conda.pth").read_text()
)

def test_develop(testing_env):
f = "https://pypi.io/packages/source/c/conda_version_test/conda_version_test-0.1.0-1.tar.gz"
download(f, "conda_version_test.tar.gz")
tar_xf("conda_version_test.tar.gz", testing_env)
extract_folder = "conda_version_test-0.1.0-1"
cwd = os.getcwd()
args = ["-p", testing_env, extract_folder]
main_develop.execute(args)
py_ver = ".".join((str(sys.version_info.major), str(sys.version_info.minor)))
with open(
os.path.join(get_site_packages(testing_env, py_ver), "conda.pth")
) as f_pth:
assert cwd in f_pth.read()
args = ["--uninstall", "-p", testing_env, extract_folder]
main_develop.execute(args)
with open(
os.path.join(get_site_packages(testing_env, py_ver), "conda.pth")
) as f_pth:
assert cwd not in f_pth.read()
main_develop.execute(["--uninstall", f"--prefix={prefix}", extract_folder])
assert (
str(Path.cwd())
not in Path(get_site_packages(prefix, py_ver), "conda.pth").read_text()
)
7 changes: 7 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,16 @@
ignore_verify_codes_default,
no_rewrite_stdout_env_default,
)
from conda_build.deprecations import deprecated
from conda_build.metadata import MetaData
from conda_build.utils import check_call_env, copy_into, prepend_bin_path
from conda_build.variants import get_default_variant

pytest_plugins = (
# Add testing fixtures and internal pytest plugins here
"conda.testing",
)


@pytest.hookimpl
def pytest_report_header(config: pytest.Config):
Expand Down Expand Up @@ -173,6 +179,7 @@ def testing_metadata(request, testing_config):


@pytest.fixture(scope="function")
@deprecated("24.9", "24.11", addendum="Use `tmp_env` fixture instead.")
def testing_env(testing_workdir, request, monkeypatch):
env_path = os.path.join(testing_workdir, "env")

Expand Down
Loading