Skip to content

Commit a1c08cf

Browse files
committed
also check parsing the entire conda env
1 parent 36019e3 commit a1c08cf

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

minimum_versions/tests/test_environments.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import pathlib
2+
import textwrap
13
from dataclasses import dataclass
24

35
import pytest
@@ -146,3 +148,40 @@ def test_parse_spec(self, spec_text, expected_spec, expected_warnings):
146148
assert actual_spec == expected_spec
147149
assert actual_name == expected_spec.name
148150
assert actual_warnings == expected_warnings
151+
152+
def test_parse_environment(self, monkeypatch):
153+
data = textwrap.dedent(
154+
"""\
155+
channels:
156+
- conda-forge
157+
dependencies:
158+
- a=1.1
159+
- b>=3.2
160+
- c=1.6.5
161+
""".rstrip()
162+
)
163+
monkeypatch.setattr(pathlib.Path, "read_text", lambda _: data)
164+
165+
expected_specs = [
166+
Spec("a", Version("1.1")),
167+
Spec("b", Version("3.2")),
168+
Spec("c", Version("1.6.5")),
169+
]
170+
expected_warnings = [
171+
("a", []),
172+
(
173+
"b",
174+
[
175+
"package must be pinned with an exact version: 'b>=3.2'."
176+
" Using the version as an exact pin instead."
177+
],
178+
),
179+
("c", ["package should be pinned to a minor version (got 1.6.5)"]),
180+
]
181+
182+
actual_specs, actual_warnings = environments.conda.parse_conda_environment(
183+
"env1.yaml", None
184+
)
185+
186+
assert actual_specs == expected_specs
187+
assert actual_warnings == expected_warnings

0 commit comments

Comments
 (0)