|
7 | 7 |
|
8 | 8 | import os |
9 | 9 | import subprocess |
| 10 | +from contextlib import ExitStack |
10 | 11 | from unittest import mock |
11 | 12 |
|
12 | 13 | from localpibox.stack import version as ver_mod |
13 | 14 | from localpibox.stack import workspace as ws_mod |
14 | 15 | from localpibox.stack import release as rel_mod |
| 16 | +from localpibox.stack import repos as repos_mod |
15 | 17 |
|
16 | 18 | ld = _load_script('lpb_devstack', SCRIPTS_DIR / 'lpb-devstack') |
17 | 19 |
|
18 | 20 | # ─── lpb-devstack: VERSION bumping ──────────────────────────────────────── |
19 | 21 |
|
20 | 22 | def _devstack_root_patch(root, tmpdir): |
21 | | - """Point stack version discovery at *root* (context manager).""" |
22 | | - return mock.patch.multiple( |
23 | | - ver_mod, |
24 | | - _DEVSTACK_ROOT=root, |
25 | | - WORKSPACE_ROOT=tmpdir / "nowhere", |
26 | | - _VERSION_FILE=None, |
27 | | - ) |
| 23 | + """Point stack version discovery at *root* (context manager). |
| 24 | +
|
| 25 | + Also neutralizes the dev release gate: without patching repo_path, the |
| 26 | + gate inspects the *real* workspace (its own module-level roots), so a |
| 27 | + dirty or unpushed local checkout would make the bump tests fail. |
| 28 | + """ |
| 29 | + stack = ExitStack() |
| 30 | + stack.enter_context(mock.patch.object(ver_mod, "_DEVSTACK_ROOT", root)) |
| 31 | + stack.enter_context(mock.patch.object(ver_mod, "WORKSPACE_ROOT", tmpdir / "nowhere")) |
| 32 | + stack.enter_context(mock.patch.object(ver_mod, "_VERSION_FILE", None)) |
| 33 | + # repo_path() resolves against repos.* at call time — patch its roots so |
| 34 | + # the gate finds no local clones (tests that need a fake gate repo patch |
| 35 | + # rel_mod.repo_path directly, which still wins). |
| 36 | + stack.enter_context(mock.patch.object( |
| 37 | + repos_mod, "WORKSPACE_ROOT", tmpdir / "nowhere")) |
| 38 | + stack.enter_context(mock.patch.object( |
| 39 | + repos_mod, "DEFAULT_AGENT_DIR", str(tmpdir / "agent"))) |
| 40 | + return stack |
28 | 41 |
|
29 | 42 |
|
30 | 43 | def test_devstack_bump_patch(tmpdir): |
|
0 commit comments