forked from conda/conda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_cli_install.py
83 lines (71 loc) · 2.47 KB
/
test_cli_install.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
from pathlib import Path
import pytest
from pytest_mock import MockerFixture
from conda.base.context import context
from conda.exceptions import UnsatisfiableError
from conda.models.match_spec import MatchSpec
from conda.testing import CondaCLIFixture, PathFactoryFixture, TmpEnvFixture
pytestmark = pytest.mark.usefixtures("parametrized_solver_fixture")
@pytest.mark.integration
def test_pre_link_message(
test_recipes_channel: Path,
mocker: MockerFixture,
tmp_env: TmpEnvFixture,
conda_cli: CondaCLIFixture,
):
mocker.patch("conda.cli.common.confirm_yn", return_value=True)
with tmp_env() as prefix:
stdout, _, _ = conda_cli(
"install",
*("--prefix", prefix),
"pre_link_messages_package",
"--yes",
)
assert "Lorem ipsum dolor sit amet" in stdout
@pytest.mark.integration
def test_find_conflicts_called_once(
mocker: MockerFixture,
tmp_env: TmpEnvFixture,
path_factory: PathFactoryFixture,
conda_cli: CondaCLIFixture,
):
if context.solver == "libmamba":
pytest.skip("conda-libmamba-solver handles conflicts differently")
bad_deps = {
"python": {
(
(
MatchSpec("statistics"),
MatchSpec("python[version='>=2.7,<2.8.0a0']"),
),
"python=3",
)
}
}
mocked_find_conflicts = mocker.patch(
"conda.resolve.Resolve.find_conflicts",
side_effect=UnsatisfiableError(bad_deps, strict=True),
)
with tmp_env("python=3.9") as prefix:
with pytest.raises(UnsatisfiableError):
# Statistics is a py27 only package allowing us a simple unsatisfiable case
conda_cli("install", "--prefix", prefix, "statistics", "--yes")
assert mocked_find_conflicts.call_count == 1
with pytest.raises(UnsatisfiableError):
conda_cli(
"install",
"--prefix",
prefix,
"statistics",
"--freeze-installed",
"--yes",
)
assert mocked_find_conflicts.call_count == 2
with pytest.raises(UnsatisfiableError):
# statistics seems to be available on 3.10 though
conda_cli(
"create", "--prefix", path_factory(), "statistics", "python=3.9", "--yes"
)
assert mocked_find_conflicts.call_count == 3