/
keorlov
/
aichess
Обзор
Документация
Войти
/
keorlov
/
aichess
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
tests/test_integration.py
68 строк
2 KB
Konstantin Orlov
wip
06 июн 2026, 13:19
06 июн 2026, 13:19
cb645b7
Код
Авторство
О чём код?
"""Integration tests — run a full tournament and verify output.""" import os import shutil import tempfile from src.tournament import run_tournament def _make_config(tmpdir, tournament_type="swiss", rounds=3): engines_dir = os.path.join(os.path.dirname(__file__), "..", "engines") return { "tournament": { "type": tournament_type, "rounds": rounds, "move_timeout": 1.0, "parallel_matches": 1, "max_moves": 200, "verbose": 0, }, "engines_dir": os.path.abspath(engines_dir), "results_dir": tmpdir, "skip_engines": ["SleepyBot", "IllegalBot", "mimo-2.5-max", "deepseek-v4-pro-max", "minimax-m3"], } def test_swiss_tournament_generates_report(): tmpdir = tempfile.mkdtemp() try: config = _make_config(tmpdir, "swiss", rounds=3) report_path = run_tournament(config) assert os.path.isfile(report_path) assert os.path.isfile(os.path.join(tmpdir, "errors.log")) games_dir = os.path.join(tmpdir, "games") assert os.path.isdir(games_dir) game_files = os.listdir(games_dir) assert len(game_files) > 0 with open(report_path, "r") as f: content = f.read() assert "Final Standings" in content assert "FirstMoveBot" in content assert "RandomBot" in content finally: shutil.rmtree(tmpdir, ignore_errors=True) def test_round_robin_tournament_generates_report(): tmpdir = tempfile.mkdtemp() try: config = _make_config(tmpdir, "round-robin") report_path = run_tournament(config) assert os.path.isfile(report_path) assert os.path.isfile(os.path.join(tmpdir, "errors.log")) games_dir = os.path.join(tmpdir, "games") game_files = os.listdir(games_dir) assert len(game_files) >= 2 # 1 match = 2 games with open(report_path, "r") as f: content = f.read() assert "Final Standings" in content assert "ROUND-ROBIN" in content finally: shutil.rmtree(tmpdir, ignore_errors=True)