Answer principles round 1: 1 🔴, 7 🟡 (0 misread); every effect is handed in as an argument, no test patches a global, and the traces principle scopes tools that run on their user's machine
CI / tests (pull_request) Successful in 3m43s

This commit is contained in:
2026-11-19 12:42:03 +01:00
parent 8ca612b7a4
commit cb3135bc8c
124 changed files with 1437 additions and 793 deletions
+1 -6
View File
@@ -1,10 +1,8 @@
"""Test doubles for the tools that read a project's config: a client's config text, and a checkout that a config names."""
import os
import pathlib
import subprocess
import tempfile
import unittest
import unittest.mock
from test_env import isolated_env
@@ -34,13 +32,10 @@ def write_config(home: pathlib.Path, checkout: pathlib.Path, goals: str = "check
def configured(test: unittest.TestCase, checkout: pathlib.Path, goals: str = "checkout:README.md", home: pathlib.Path | None = None) -> pathlib.Path:
"""Makes checkout a git checkout that a config names, under home, else a HOME of its own, for the rest of the test; the config's folder."""
"""Makes checkout a git checkout that a config names, under home, else under a folder of its own for the rest of the test; the config's folder, two levels under that home."""
subprocess.run(["git", "init", "--quiet", str(checkout)], check=True, env=isolated_env())
if home is None:
made = tempfile.TemporaryDirectory()
test.addCleanup(made.cleanup)
home = pathlib.Path(made.name)
patched = unittest.mock.patch.dict(os.environ, {"HOME": str(home)})
patched.start()
test.addCleanup(patched.stop)
return write_config(home, checkout, goals)
@@ -4,7 +4,6 @@ import subprocess
import sys
import tempfile
import unittest
import unittest.mock
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))