test_trademark_notice.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/usr/bin/env python3
  2. # SPDX-License-Identifier: AGPL-3.0-or-later
  3. """
  4. The trademark notice sentence lives in TRADEMARKS.md; the files below carry it verbatim.
  5. If this test fails, TRADEMARKS.md was changed (or one of these files was): update the others.
  6. """
  7. import os
  8. import re
  9. import unittest
  10. ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  11. COPIES = (
  12. 'README.rst',
  13. 'CONTRIBUTING.md',
  14. 'html/img/README-TRADEMARKS.md',
  15. 'html/desktop-tou.html',
  16. )
  17. def read(path):
  18. with open(os.path.join(ROOT, path), encoding='utf-8') as fh:
  19. return fh.read()
  20. class TrademarkNoticeTest(unittest.TestCase):
  21. def canonical(self):
  22. match = re.search(r'^The MOD logo is a registered trademark \(.*\)\.$', read('TRADEMARKS.md'), re.M)
  23. self.assertIsNotNone(match, 'TRADEMARKS.md has no notice sentence')
  24. return match.group(0)
  25. def test_copies_match_trademarks_md(self):
  26. sentence = self.canonical()
  27. for path in COPIES:
  28. with self.subTest(path=path):
  29. self.assertIn(sentence, read(path))
  30. if __name__ == '__main__':
  31. unittest.main()