Skip to content

fix-test-tests-forges-test-github-api-url-py-test-with-no-set-fb2349ad/1: Restore settings fields after each test so a doctor reload does not leak into test_with_no_setting_the_forge_calls_github - #983

Merged
bwmatson merged 1 commit into
mainfrom
spec/fix-test-tests-forges-test-github-api-url-py-test-with-no-set-fb2349ad/1
Nov 16, 2026
Merged

bwmatson merged 1 commit into
mainfrom
spec/fix-test-tests-forges-test-github-api-url-py-test-with-no-set-fb2349ad/1

Conversation

@bwmatson

Copy link
Copy Markdown
Owner

Start here

Already verified by the pipeline

  • unit-test result: passed
  • Review took 1 review round

Review tier: full — the planned estimate is full

Why

agent_build_kit.settings.reload writes a fresh read of the environment into the one process-wide settings object, in
place, field by field (src/agent_build_kit/settings.py:228). Loading an installation calls it
(Installation.activate and load_config, src/agent_build_kit/installation.py:344 and :384), and so does
run_doctor. monkeypatch.setenv puts the environment back after a test. It does not put back the settings fields

… The full reason is in openspec/changes/fix-test-tests-forges-test-github-api-url-py-test-with-no-set-fb2349ad/proposal.md.

What this pull request does

Done when the doctor-with-setting test followed by the failing test passes in one process with no workers (on the base the second fails with NotFound: POST /api/v3/repos/example/app/pulls), no confirmed test below leaves a settings field changed after it ends, and the changed tests pass under the repeat check.

Every test now ends with the process-wide settings it started with, so a test that reloads them from a patched environment no longer leaks its values into later tests on the same worker.

  • An autouse settings_restored fixture in tests/conftest.py snapshots every field of the shared settings object and the loaded .env path before each test and writes them back afterwards.
  • After a doctor test that set ABK_GITHUB_API_URL, the forge test with no setting again calls api.github.com instead of the address the earlier test left behind.
  • The token fixture in tests/forges/test_github_api_url.py also undoes its monkeypatching and reloads the settings from the environment at teardown, and the module docstring describes that.

Based on main, with nothing unmerged beneath it — ready to merge whenever the checks look right.

Unit fix-test-tests-forges-test-github-api-url-py-test-with-no-set-fb2349ad/1 of change fix-test-tests-forges-test-github-api-url-py-test-with-no-set-fb2349ad, task group(s) 1.
Spec: openspec/changes/fix-test-tests-forges-test-github-api-url-py-test-with-no-set-fb2349ad/ in the planning repo.

Assumptions

This unit assumes nothing unmerged: everything it builds on is already in main.

Verification

This is a unit-test unit: everything it needs is fakes, fixtures or throwaway containers, so GitHub Actions runs the whole of it. No e2e-test run was required.

Left for later

Approved, with these recorded rather than blocking:

  • With settings_restored autouse in tests/conftest.py, the many per-test reload(None) teardowns across tests/ (for example tests/cli/test_doctor_grafana.py, tests/serve/test_serve_metrics.py, tests/account_settings.py:40) are now redundant. A later cleanup could remove them so there is one place that restores the settings.
  • tests/forges/test_github_api_url.py:42 — The token fixture's new monkeypatch.undo(); reload(None) teardown does the same job as the new autouse settings_restored fixture in tests/conftest.py:87. That root fixture is set up before token and torn down after it, so it overwrites whatever reload(None) wrote. The per-file teardown has no effect, and the module docstring (lines 6-8) credits the wrong fixture for the isolation.

How this was built

The commit order is checked mechanically; lint, formatting and types pass at the tip.


Opened by the spec-driven pipeline. The build agent never merges. The pipeline merges only
a unit review classified auto and policy allowed; a person merges any other, after checking
the stack order above.

…_the_forge_calls_github` deterministic

The tests come first and fail until the implementation.

`agent_build_kit.settings.reload` writes a fresh read of the environment into the one process-wide `settings` object, in place, field by field (`src/agent_build_kit/settings.py:228`).

Done when the doctor-with-setting test followed by the failing test passes in one process with no workers (on the base the second fails with `NotFound: POST /api/v3/repos/example/app/pulls`), no…

Unit: fix-test-tests-forges-test-github-api-url-py-test-with-no-set-fb2349ad/1
@bwmatson bwmatson added change-fix-test-tests-forges-test-github-api-url-p The change this pull request belongs to checking In review, but its checks are still running review-full Review asks for a full read from a person in-review Built and waiting for human review and removed checking In review, but its checks are still running labels Nov 16, 2026
@bwmatson
bwmatson merged commit 25df363 into main Nov 16, 2026
5 checks passed
@bwmatson bwmatson added settling Merged; waiting for its checks to complete and removed in-review Built and waiting for human review settling Merged; waiting for its checks to complete labels Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change-fix-test-tests-forges-test-github-api-url-p The change this pull request belongs to review-full Review asks for a full read from a person

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant