test(web-app-docs): give the conf import the values it requires

conf.py reads DOCS_SPHINX_PROJECT, _COPYRIGHT and _AUTHOR with os.environ[...] since 9dc7f0cbc2, because a missing value must stop the build rather than render an empty project name into every title and the footer. The test loads the module at import time with only sys.argv patched, so it raised KeyError.

Supply the three through _REQUIRED_ENV in the same patch block that loads the module, and again in the reload test, whose own patch.dict opens after the import patch has closed. The test now states the requirement instead of a default hiding it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
kevinveenbirkenbachandClaude Opus 5 committed 2026-10-15 23:24:28 +02:00
1 parent af01bd58a9
commit 00393bb1b1
1 file changed
+8 -2
@@ -16,7 +16,13 @@ _TOOLING = str(PROJECT_ROOT / "roles" / "web-app-docs" / "files" / "python")
if _TOOLING not in sys.path:
sys.path.insert(0, _TOOLING)
with patch.object(sys, "argv", ["sphinx-build"]):
_REQUIRED_ENV = {
"DOCS_SPHINX_PROJECT": "Infinito.Nexus",
"DOCS_SPHINX_COPYRIGHT": "2025, Kevin Veen-Birkenbach",
"DOCS_SPHINX_AUTHOR": "Kevin Veen-Birkenbach",
}
with patch.object(sys, "argv", ["sphinx-build"]), patch.dict("os.environ", _REQUIRED_ENV):
conf = importlib.import_module("infinito_docs.conf")
@@ -64,7 +70,7 @@ class TestConf(unittest.TestCase):
)
def test_built_version_comes_from_the_environment(self) -> None:
with patch.dict("os.environ", {"DOCS_VERSION": "v1.2.3"}):
with patch.dict("os.environ", {**_REQUIRED_ENV, "DOCS_VERSION": "v1.2.3"}):
reloaded = importlib.reload(conf)
self.assertEqual(reloaded.html_context, {"docs_version": "v1.2.3"})
self.assertIn("versions.html", reloaded.html_sidebars["**"])