|
| 1 | +import io |
1 | 2 | import pathlib |
2 | 3 | import textwrap |
3 | 4 | from dataclasses import dataclass |
@@ -238,3 +239,36 @@ def test_parse_spec(self, name, version_text, expected_spec, expected_warnings): |
238 | 239 | def test_parse_spec_error(self, version_text): |
239 | 240 | with pytest.raises(ValueError, match="Unknown version format: .*"): |
240 | 241 | 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