Skip to content

Commit c7c1179

Browse files
committed
checks for parse_pixi_environment
1 parent 7f9863b commit c7c1179

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

minimum_versions/tests/test_environments.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import io
12
import pathlib
23
import textwrap
34
from dataclasses import dataclass
@@ -238,3 +239,36 @@ def test_parse_spec(self, name, version_text, expected_spec, expected_warnings):
238239
def test_parse_spec_error(self, version_text):
239240
with pytest.raises(ValueError, match="Unknown version format: .*"):
240241
environments.pixi.parse_spec("package", version_text)
242+
243+
def test_parse_pixi_environment(self, monkeypatch):
244+
data = textwrap.dedent(
245+
"""\
246+
[dependencies]
247+
a = "1.0.*"
248+
b = "2.2.*"
249+
250+
[feature.feature1.dependencies]
251+
c = "3.1.*"
252+
253+
[environments]
254+
env1 = { features = ["feature1"] }
255+
""".rstrip()
256+
)
257+
monkeypatch.setattr(
258+
pathlib.Path, "open", lambda _, mode: io.BytesIO(data.encode())
259+
)
260+
261+
name = "env1"
262+
manifest_path = pathlib.Path("pixi.toml")
263+
264+
actual_specs, actual_warnings = environments.pixi.parse_pixi_environment(
265+
name, manifest_path
266+
)
267+
expected_specs = [
268+
Spec("a", Version("1.0")),
269+
Spec("b", Version("2.2")),
270+
Spec("c", Version("3.1")),
271+
]
272+
expected_warnings = [("a", []), ("b", []), ("c", [])]
273+
assert actual_specs == expected_specs
274+
assert actual_warnings == expected_warnings

0 commit comments

Comments
 (0)