diff --git a/scripts/tests/test_docs_only_detector_clone_depth.py b/scripts/tests/test_docs_only_detector_clone_depth.py index 16e4dfd86..1855715fc 100644 --- a/scripts/tests/test_docs_only_detector_clone_depth.py +++ b/scripts/tests/test_docs_only_detector_clone_depth.py @@ -53,25 +53,19 @@ def _env(**extra: str) -> dict[str, str]: the next arm that starts reading a sibling — the whole prefix goes, and `_run_detector` puts back exactly what each test means to set. """ - env = { - k: v for k, v in os.environ.items() if not k.startswith(("GIT_", "GITHUB_")) - } + env = {k: v for k, v in os.environ.items() if not k.startswith(("GIT_", "GITHUB_"))} env.update(extra) return env def _git(args: list[str], cwd: Path) -> str: - r = subprocess.run( - ["git", *args], cwd=str(cwd), env=_env(), capture_output=True, text=True - ) + r = subprocess.run(["git", *args], cwd=str(cwd), env=_env(), capture_output=True, text=True) assert r.returncode == 0, f"git {' '.join(args)} failed: {r.stderr}" return r.stdout.strip() def _git_rc(args: list[str], cwd: Path) -> subprocess.CompletedProcess: - return subprocess.run( - ["git", *args], cwd=str(cwd), env=_env(), capture_output=True, text=True - ) + return subprocess.run(["git", *args], cwd=str(cwd), env=_env(), capture_output=True, text=True) def _is_shallow(repo: Path) -> str: @@ -232,9 +226,7 @@ def test_the_push_arm_leaves_a_COMPLETE_clone_complete(origin_url, tmp_path): repo = _clone(origin_url, tmp_path / "build-shape") assert _is_shallow(repo) == "false" - r, output = _run_detector( - repo, tmp_path, GITHUB_EVENT_NAME="push", GITHUB_REF_NAME="main" - ) + r, output = _run_detector(repo, tmp_path, GITHUB_EVENT_NAME="push", GITHUB_REF_NAME="main") assert r.returncode == 0, f"detector failed: {r.stdout}{r.stderr}" assert _is_shallow(repo) == "false", ( @@ -277,9 +269,7 @@ def test_the_pull_request_arm_leaves_a_COMPLETE_clone_complete(deep_origin_url, _git(["add", "-A"], repo) _git(["commit", "-q", "-m", "docs on the PR head"], repo) - r, output = _run_detector( - repo, tmp_path, GITHUB_EVENT_NAME="pull_request", GITHUB_BASE_REF="main" - ) + r, output = _run_detector(repo, tmp_path, GITHUB_EVENT_NAME="pull_request", GITHUB_BASE_REF="main") assert r.returncode == 0, f"detector failed: {r.stdout}{r.stderr}" assert _is_shallow(repo) == "false", ( @@ -310,9 +300,7 @@ def test_a_SHALLOW_checkout_still_gets_its_depth_and_still_decides(origin_url, t repo = _clone(origin_url, tmp_path / "shallow-shape", depth=2) assert _is_shallow(repo) == "true", "the fixture clone was meant to be shallow" - r, output = _run_detector( - repo, tmp_path, GITHUB_EVENT_NAME="push", GITHUB_REF_NAME="main" - ) + r, output = _run_detector(repo, tmp_path, GITHUB_EVENT_NAME="push", GITHUB_REF_NAME="main") assert r.returncode == 0, f"detector failed: {r.stdout}{r.stderr}" assert _is_shallow(repo) == "true", "a shallow checkout was silently unshallowed" @@ -320,9 +308,7 @@ def test_a_SHALLOW_checkout_still_gets_its_depth_and_still_decides(origin_url, t "the shallow checkout no longer classifies the docs-only merge — the depth stopped being " f"applied where it IS needed:\n{r.stdout}\n{output}" ) - assert "fetching with --depth=2" in r.stdout, ( - f"the shallow checkout did not take the depth branch:\n{r.stdout}" - ) + assert "fetching with --depth=2" in r.stdout, f"the shallow checkout did not take the depth branch:\n{r.stdout}" assert "fetching without --depth" not in r.stdout, ( f"the shallow checkout took the complete-clone branch:\n{r.stdout}" ) @@ -346,12 +332,6 @@ def test_an_UNKNOWN_shallow_answer_passes_no_depth(tmp_path): """ notarepo = tmp_path / "notarepo" notarepo.mkdir() - r, _output = _run_detector( - notarepo, tmp_path, GITHUB_EVENT_NAME="push", GITHUB_REF_NAME="main" - ) - assert "is-shallow=unknown" in r.stdout, ( - f"the unknown answer was not reached or not reported:\n{r.stdout}" - ) - assert "fetching without --depth" in r.stdout, ( - f"an unknown shallow answer must not ask for a depth:\n{r.stdout}" - ) + r, _output = _run_detector(notarepo, tmp_path, GITHUB_EVENT_NAME="push", GITHUB_REF_NAME="main") + assert "is-shallow=unknown" in r.stdout, f"the unknown answer was not reached or not reported:\n{r.stdout}" + assert "fetching without --depth" in r.stdout, f"an unknown shallow answer must not ask for a depth:\n{r.stdout}"