Files
claude-config/bin/repo_checks/test_task_bench_image.py
T
2026-11-23 23:31:55 +01:00

25 lines
988 B
Python

import pathlib
import re
import sys
import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from run_tests.main import PYTEST
from repo_checks import ROOT
DOCKERFILE = (ROOT / "task-bench-image" / "Dockerfile").read_text(encoding="utf-8")
class TaskBenchImage(unittest.TestCase):
def test_the_image_has_the_python_tag_that_ci_sh_runs(self):
images = re.findall(r"^FROM (python:\S+)$", DOCKERFILE, re.MULTILINE)
self.assertEqual(len(images), 1, "task-bench-image/Dockerfile starts from one python image")
# ci.sh prints its Dockerfile with printf, so the line ends in a backslash and an n.
self.assertIn(f"FROM {images[0]}\\n", (ROOT / "ci.sh").read_text(encoding="utf-8"))
def test_the_image_installs_the_pytest_pins_that_run_tests_uses(self):
installed = set(re.findall(r"\b(pytest(?:-xdist)?==[\d.]+)", DOCKERFILE))
pins = {word for word in PYTEST if re.fullmatch(r"pytest(?:-xdist)?==[\d.]+", word)}
self.assertEqual(installed, pins)