Files
uconsole_asw_game/tests/test_calibration.py
T
Claude f7f5462265 Release only after green tests, CI on Windows and Python 3.13, required update checksum (1.3.215)
The publish job now waits for the Tests workflow of its commit and gives up
on a failure, so a red main never reaches the updaters. A failed Windows
build no longer holds back the uConsole/macOS release; older releases are
kept while the new one lacks the Windows program. Windows/macOS updates are
offered only with GitHub's SHA-256 digest. Tests: pytest on Windows and
Python 3.13, browser tests selected by the browser marker, pytest-timeout
with a 15 min default, calibration split per section.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G3tXxmJcADkJ8r7XDY1dq8
2026-10-05 14:46:20 +00:00

51 lines
1.8 KiB
Python

"""Physics upgrades must keep the recorded 1.0.0 gameplay calibration."""
import importlib.util
import json
import os
import pytest
pytestmark = pytest.mark.slow # generation/calibration runs above 20 s
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
def _tool():
spec = importlib.util.spec_from_file_location(
"calibrate", os.path.join(ROOT, "tools", "calibrate.py"))
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
return module
def test_every_golden_metric_belongs_to_a_section():
tool = _tool()
golden = tool.load_json(tool.GOLDEN_PATH, None)
assert golden is not None and golden["metrics"]
for key in golden["metrics"]:
assert tool.section_of(key) in tool.SECTIONS, key
# One test per section, so the parallel runner spreads the long measurement.
@pytest.mark.parametrize("section", ["ship", "sonar", "radar", "torpedo", "sub",
"damage", "air"])
def test_golden_calibration_holds_within_tolerance(section):
tool = _tool()
assert section in tool.SECTIONS
golden = tool.golden_for_sections(tool.load_json(tool.GOLDEN_PATH, None), [section])
assert golden["metrics"]
problems = tool.compare(tool.measure_all([section]), golden,
tool.load_json(tool.DEVIATIONS_PATH, {}))
assert problems == []
def test_every_deviation_is_justified_and_known():
tool = _tool()
golden = tool.load_json(tool.GOLDEN_PATH, None)
with open(tool.DEVIATIONS_PATH, encoding="utf-8") as handle:
deviations = json.load(handle)
for key, entry in deviations.items():
assert key in golden["metrics"], key
assert isinstance(entry.get("reason"), str) and len(entry["reason"]) > 20
assert set(entry) <= {"reason", "value", "tolerance", "phase"}