[GEMINI] Refactor tests to use Config class and autouse test isolation fixture

This commit is contained in:
venus
2026-07-19 02:55:11 -05:00
parent 7691b366f2
commit 7bd450abed
5 changed files with 129 additions and 169 deletions

27
tests/conftest.py Normal file
View File

@@ -0,0 +1,27 @@
# tests/conftest.py
import pytest
import toml
from pathlib import Path
@pytest.fixture(autouse=True)
def setup_test_config(tmp_path, monkeypatch):
"""Autouse fixture to isolate test runs from the real config.toml."""
test_config = tmp_path / "config.toml"
default_data = {
"Competition": {
"competition": "picoctf",
"catagory": "textCat",
"challenge": "testChal",
"flag_format": r"picoCTF\{.*\}",
"last_flag": "flag{my_flag_here}"
},
"Enviroment": {
"ctf_dir": "/home/venus/ctf"
}
}
test_config.parent.mkdir(parents=True, exist_ok=True)
with open(test_config, "w") as f:
toml.dump(default_data, f)
monkeypatch.setenv("CTF_CONFIG_PATH", str(test_config))
return test_config