Download tests/test_config_example.py from elyanlabs/trashclaw: direct link, hf CLI and curl.
- Browser
- Download file 1.26 kB
-
https://huggingface.co/elyanlabs/trashclaw/resolve/main/tests/test_config_example.py
- Command line
-
hf download hf://elyanlabs/trashclaw/tests/test_config_example.py
-
curl -L -o test_config_example.py https://huggingface.co/elyanlabs/trashclaw/resolve/main/tests/test_config_example.py
1.26 kB
| # 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") | |
| 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") | |