Skip to content

Commit

Permalink
Test for Multiple Categories
Browse files Browse the repository at this point in the history
  • Loading branch information
srilman committed Nov 24, 2023
1 parent 1aa1f52 commit 94c68e4
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions tests/test_conda_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
_add_auth_to_line,
_add_auth_to_lockfile,
_extract_domain,
_solve_for_arch,
_strip_auth_from_line,
_strip_auth_from_lockfile,
create_lockfile_from_spec,
Expand Down Expand Up @@ -592,6 +593,7 @@ def test_choose_wheel() -> None:
platform="linux-64",
)
assert len(solution) == 1
assert solution["fastavro"].categories == {"main"}
assert solution["fastavro"].hash == HashModel(
sha256="a111a384a786b7f1fd6a8a8307da07ccf4d4c425084e2d61bae33ecfb60de405"
)
Expand Down Expand Up @@ -1578,6 +1580,54 @@ def test_run_lock_with_input_hash_check(
assert "Spec hash already locked for" in output.err


def test_solve_arch_multiple_categories():
_conda_exe = determine_conda_executable(None, mamba=False, micromamba=False)
vpr = default_virtual_package_repodata()
channels = [Channel.from_string("conda-forge")]

with vpr, tempfile.NamedTemporaryFile(dir=".") as tf:
spec = LockSpecification(
dependencies={
"linux-64": [
VersionedDependency(
name="python",
version="=3.10.9",
manager="conda",
category="main",
extras=[],
),
VersionedDependency(
name="pandas",
version="=1.5.3",
manager="conda",
category="test",
extras=[],
),
VersionedDependency(
name="pyarrow",
version="=9.0.0",
manager="conda",
category="dev",
extras=[],
),
],
},
channels=channels,
# NB: this file must exist for relative path resolution to work
# in create_lockfile_from_spec
sources=[Path(tf.name)],
virtual_package_repo=vpr,
)

locked_deps = _solve_for_arch(_conda_exe, spec, "linux-64", channels)
python_deps = [dep for dep in locked_deps if dep.name == "python"]
assert len(python_deps) == 1
assert python_deps[0].categories == {"main", "test", "dev"}
numpy_deps = [dep for dep in locked_deps if dep.name == "numpy"]
assert len(numpy_deps) == 1
assert numpy_deps[0].categories == {"test", "dev"}


@pytest.mark.parametrize(
"package,version,url_pattern",
[
Expand Down

0 comments on commit 94c68e4

Please sign in to comment.