Skip to content

Commit 8ac37fc

Browse files
committed
fix(tests): parse pyproject.toml with tomllib, remove unused fixture
- Use tomllib to parse force-include keys from the actual TOML table instead of raw substring search (avoids false positives) - Remove unused source_template_stems fixture from test_scaffold_command_dir_location
1 parent b83873e commit 8ac37fc

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

tests/test_core_pack_scaffold.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import re
3434
import shutil
3535
import subprocess
36+
import tomllib
3637
import zipfile
3738
from pathlib import Path
3839

@@ -241,7 +242,7 @@ def test_scaffold_creates_specify_templates(agent, scaffolded_sh):
241242

242243

243244
@pytest.mark.parametrize("agent", _TESTABLE_AGENTS)
244-
def test_scaffold_command_dir_location(agent, scaffolded_sh, source_template_stems):
245+
def test_scaffold_command_dir_location(agent, scaffolded_sh):
245246
"""Command files land in the directory declared by AGENT_CONFIG."""
246247
project = scaffolded_sh(agent)
247248

@@ -565,11 +566,13 @@ def test_pyproject_force_include_covers_all_templates():
565566
assert repo_template_files, "Expected at least one template file in templates/"
566567

567568
pyproject_path = _REPO_ROOT / "pyproject.toml"
568-
pyproject_text = pyproject_path.read_text()
569+
with open(pyproject_path, "rb") as f:
570+
pyproject = tomllib.load(f)
571+
force_include = pyproject.get("tool", {}).get("hatch", {}).get("build", {}).get("targets", {}).get("wheel", {}).get("force-include", {})
569572

570573
missing = [
571574
name for name in repo_template_files
572-
if f"templates/{name}" not in pyproject_text
575+
if f"templates/{name}" not in force_include
573576
]
574577
assert not missing, (
575578
"Template files not listed in pyproject.toml force-include "

0 commit comments

Comments
 (0)