tests/test_hygiene.py — Docs vs Code Checker

From version 0.1.0 of Docs vs Code Checker, shown publicly by its creator. 2.5 KiB · SHA-256 55d0030c845e99f65d20c41100bb5593042caac050eabb8821ddf356a7abea96.

"""Check the complete shipped-file surface for publication hygiene.

By Zero Width Lab (zerowidthlab.com)
"""
from __future__ import annotations

import os
import re
import unicodedata
import unittest
from pathlib import Path

__author__ = "Zero Width Lab"
ROOT = Path(__file__).resolve().parent.parent
SIGNATURE = "By Zero Width Lab (zerowidthlab.com)"
SHIPPED = {
    "SKILL.md", "README.md", "SETUP.md", "LICENSE.txt", "agents/docs-vs-code-checker.md",
    "references/method.md", "scripts/docs_claims.py", "tests/test_docs_claims.py", "tests/test_hygiene.py",
    "tests/fixtures/mini-repo/README.md", "tests/fixtures/mini-repo/app.py", "source-package.json",
}


class HygieneTests(unittest.TestCase):
    def test_shipped_files(self) -> None:
        for path in SHIPPED:
            self.assertTrue((ROOT / path).is_file(), path)

    def test_publication_hygiene(self) -> None:
        invisible = {chr(number) for number in range(0x200B, 0x2010)} | {chr(0xFEFF), chr(0x2060)}
        forbidden_names = (
            "Open" + "AI", "Anth" + "ropic", "Chat" + "G" + "PT", "Gem" + "ini",
            "Clau" + "de", "Co" + "dex", "Co" + "pilot", "Son" + "net", "Op" + "us",
        )
        token_name = "G" + "PT"
        for relative in SHIPPED:
            path = ROOT / relative
            content = path.read_text(encoding="utf-8")
            with self.subTest(path=relative):
                self.assertFalse(any(char in content for char in invisible))
                self.assertFalse(any(unicodedata.category(char) in {"Cf", "Zl", "Zp"} for char in content))
                self.assertIsNone(re.search(r"(?i)\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b", content))
                self.assertIsNone(re.search(r"(?i)\b[\w.+-]+@[\w.-]+\.[a-z]{2,}\b", content))
                self.assertIsNone(re.search(r"(?i)\b[a-z0-9-]+\.onmicrosoft\.com\b", content))
                self.assertIsNone(re.search(r"/(?:Users|home)/[A-Za-z][^/\s]*", content))
                for name in forbidden_names:
                    self.assertNotIn(name.casefold(), content.casefold())
                self.assertIsNone(re.search(r"\b" + token_name + r"\b", content))
                if path.suffix == ".md":
                    self.assertEqual(content.strip().splitlines()[-1], SIGNATURE)
                if path.suffix == ".py":
                    self.assertIn(SIGNATURE, content[:220])
                    self.assertIn('__author__ = "Zero Width Lab"', content)


if __name__ == "__main__":
    unittest.main()

License: MIT (read it).

MITMIT License

Copyright (c) 2026 Zero Width Lab

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Back to the listing