Skip to content

Commit 113d767

Browse files
committed
check the format detection
1 parent 56aab76 commit 113d767

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

minimum_versions/environments/pixi.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,14 @@ def parse_pixi_environment(name: str, manifest_path: pathlib.Path | None):
6767
with manifest_path.open(mode="rb") as f:
6868
data = tomllib.load(f)
6969

70-
if manifest_path.name == "pixi.toml":
71-
pixi_config = data
72-
else:
73-
pixi_config = get_in(["pixi", "tool"], data, None)
70+
if manifest_path.name == "pyproject.toml":
71+
pixi_config = get_in(["tool", "pixi"], data, None)
7472
if pixi_config is None:
7573
raise ValueError(
7674
f"The 'tool.pixi' section is missing from {manifest_path}."
7775
)
76+
else:
77+
pixi_config = data
7878

7979
environment_definitions = pixi_config.get("environments")
8080
if environment_definitions is None:

minimum_versions/tests/test_environments.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def test_parse_spec_error(self, version_text):
241241
environments.pixi.parse_spec("package", version_text)
242242

243243
@pytest.mark.parametrize(
244-
["data", "expected_specs", "expected_warnings"],
244+
["data", "path", "expected_specs", "expected_warnings"],
245245
(
246246
pytest.param(
247247
textwrap.dedent(
@@ -257,6 +257,7 @@ def test_parse_spec_error(self, version_text):
257257
env1 = { features = ["feature1"] }
258258
""".rstrip()
259259
),
260+
"pixi.toml",
260261
[
261262
Spec("a", Version("1.0")),
262263
Spec("b", Version("2.2")),
@@ -279,6 +280,7 @@ def test_parse_spec_error(self, version_text):
279280
env1 = { features = ["feature1"], no-default-feature = true }
280281
""".rstrip()
281282
),
283+
"pixi.toml",
282284
[Spec("c", Version("3.1"))],
283285
[("c", [])],
284286
id="no-default-feature",
@@ -293,21 +295,37 @@ def test_parse_spec_error(self, version_text):
293295
env1 = { features = [] }
294296
""".rstrip()
295297
),
298+
"pixi.toml",
296299
[Spec("a", Version("1.0"))],
297300
[("a", [])],
298301
id="missing-features",
299302
),
303+
pytest.param(
304+
textwrap.dedent(
305+
"""\
306+
[tool.pixi.feature.feature1.dependencies]
307+
c = "3.1.*"
308+
309+
[tool.pixi.environments]
310+
env1 = { features = ["feature1"], no-default-feature = true }
311+
""".rstrip()
312+
),
313+
"pyproject.toml",
314+
[Spec("c", Version("3.1"))],
315+
[("c", [])],
316+
id="pyproject",
317+
),
300318
),
301319
)
302320
def test_parse_pixi_environment(
303-
self, monkeypatch, data, expected_specs, expected_warnings
321+
self, monkeypatch, path, data, expected_specs, expected_warnings
304322
):
305323
monkeypatch.setattr(
306324
pathlib.Path, "open", lambda _, mode: io.BytesIO(data.encode())
307325
)
308326

309327
name = "env1"
310-
manifest_path = pathlib.Path("pixi.toml")
328+
manifest_path = pathlib.Path(path)
311329

312330
actual_specs, actual_warnings = environments.pixi.parse_pixi_environment(
313331
name, manifest_path

0 commit comments

Comments
 (0)