Files
horizon-airdef/tests/test_parity.py
T
Ludovic Marie 6fdd7f3bd7 Add the Horizon logo, banner and in-game screenshots to the README
An original logo (a sun setting behind a blocky horizon), a banner and a social
preview card, and six screenshots captured in the Rust client. The README opens
with badges, a short pitch and a gallery; a test keeps the parity badge in step
with the subsystem table. Packaged builds use the logo as their menu icon.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 02:47:52 +02:00

24 lines
1.1 KiB
Python

import re
import unittest
from pathlib import Path
README = Path(__file__).resolve().parents[1] / 'README.md'
class ParityTests(unittest.TestCase):
def test_readme_percentage_matches_table(self):
text = README.read_text()
heading = re.search(r'^### Java parity: (\d+)%$', text, re.MULTILINE)
self.assertIsNotNone(heading, 'README parity heading is missing')
table = text[heading.end():].split('| Subsystem | Score | Main gaps |', 1)[1].split('\n\n', 1)[0]
scores = [float(score) for score in re.findall(r'^\| [^|]+ \| (0|0\.25|0\.5|0\.75|1) \| [^|]+ \|$', table, re.MULTILINE)]
self.assertEqual(len(scores), table.count('\n|') - 1, 'Every row needs a score of 0, 0.25, 0.5, 0.75 or 1')
self.assertEqual(int(heading.group(1)), round(sum(scores) * 100 / len(scores)))
badge = re.search(r'badge/vanilla%20parity-(\d+)%25-', text)
self.assertIsNotNone(badge, 'README parity badge is missing')
self.assertEqual(badge.group(1), heading.group(1), 'The parity badge must match the table')
if __name__ == '__main__':
unittest.main()