# SPDX-License-Identifier: MIT """The shipped .trashclaw.toml.example must only use keys a project config honours. Project configs are untrusted, so url, auto_shell, max_rounds, max_context (and anything else outside PROJECT_CONFIG_ALLOWED_KEYS) are ignored with a warning. An example that sets them tells users something that does not work. """ import os import shutil import sys sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) import pytest import trashclaw EXAMPLE = os.path.join(os.path.dirname(os.path.dirname(__file__)), ".trashclaw.toml.example") @pytest.mark.parametrize("use_fallback_parser", [False, True]) def test_example_only_uses_honoured_keys(tmp_path, monkeypatch, capsys, use_fallback_parser): if use_fallback_parser: monkeypatch.setitem(sys.modules, "tomllib", None) # Python < 3.11 path monkeypatch.setattr(trashclaw, "CONFIG_FILE", str(tmp_path / "no-home-config.json")) shutil.copy(EXAMPLE, str(tmp_path / ".trashclaw.toml")) cfg = trashclaw._load_config(str(tmp_path)) err = capsys.readouterr().err assert "Ignoring" not in err, err assert cfg.get("model") assert isinstance(cfg.get("context_files"), list) and cfg["context_files"] assert cfg.get("project_system_prompt")