Skip to content

Commit

Permalink
Add test_add_pip_as_python_dependency_from_condarc_file
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Bargull <[email protected]>
  • Loading branch information
mbargull committed Nov 26, 2023
1 parent b2520f5 commit 48d42ce
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/test_api_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import tarfile
import uuid
from collections import OrderedDict
from contextlib import nullcontext
from glob import glob
from pathlib import Path
from shutil import which
Expand All @@ -28,8 +29,10 @@
import conda_build
from conda_build import __version__, api, exceptions
from conda_build.conda_interface import (
CONDA_VERSION,
CondaError,
LinkError,
VersionOrder,
cc_conda_build,
context,
reset_context,
Expand Down Expand Up @@ -1899,3 +1902,37 @@ def test_activated_prefixes_in_actual_path(testing_metadata):
if path in expected_paths
]
assert actual_paths == expected_paths


@pytest.mark.parametrize("add_pip_as_python_dependency", [False, True])
def test_add_pip_as_python_dependency_from_condarc_file(
testing_metadata, testing_workdir, add_pip_as_python_dependency, monkeypatch
):
"""
Test whether settings from .condarc files are heeded.
ref: https://github.com/conda/conda-libmamba-solver/issues/393
"""
if (
not add_pip_as_python_dependency
and context.solver == "libmamba"
and VersionOrder(CONDA_VERSION) <= VersionOrder("23.10.0")
):
pytest.xfail("conda.plan.install_actions from conda<=23.10.0 ignores .condarc files.")
testing_metadata.meta["build"]["script"] = ['python -c "import pip"']
testing_metadata.meta["requirements"]["host"] = ["python"]
del testing_metadata.meta["test"]
if add_pip_as_python_dependency:
check_build_fails = nullcontext()
else:
check_build_fails = pytest.raises(subprocess.CalledProcessError)

# For conda<=23.10.0, ContextStack's pop/replace methods don't call self.apply.
from conda.base.context import context_stack

context_stack.apply()

conda_rc = Path(testing_workdir, ".condarc")
conda_rc.write_text(f"add_pip_as_python_dependency: {add_pip_as_python_dependency}")
with env_var("CONDARC", conda_rc, reset_context):
with check_build_fails:
api.build(testing_metadata)

0 comments on commit 48d42ce

Please sign in to comment.