Files
coding-bench/tasks/D/d-10/check/check_task.py

25 lines
1001 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""Checkliste für d-10 (Snake). Alle Punkte stehen im Aufgabentext (prompt.md)."""
import sys
from snakecheck import run_snake_checks
from webcheck import Checklist, Session
cl = Checklist()
with Session() as s:
if not s.open():
cl.add("index.html vorhanden", False, "Datei /work/index.html fehlt", weight=2)
cl.finish()
sys.exit(0)
s.wait(0.5)
cl.add("lädt ohne JavaScript-Fehler", not s.errors, "; ".join(s.errors[:2]), weight=2)
run_snake_checks(cl, s)
cl.add("kein Zugriff aufs Netz", not s.blocked, f"versucht: {s.blocked[:2]}")
s.screenshot() # Zustand am Ende der Prüfung (nach dem Neustart: laufendes Spiel)
cl.guard(
"passt in 1280×800 ohne Scrollen",
lambda: (
lambda w, h, iw, ih: (w <= iw + 1 and h <= ih + 1, f"Seite {w}x{h} in Fenster {iw}x{ih}")
)(*s.page.evaluate("[document.documentElement.scrollWidth, document.documentElement.scrollHeight, innerWidth, innerHeight]")),
)
cl.finish()