Stop the test suite exiting 0 after 10% of its tests

`pytest src/tests` died at 123 of 1170 tests with exit code 0 -- no summary,
no coverage report, and a shell that saw success. Four tests reach code
paths that call os._exit(0), which skips interpreter finalization and takes
pytest with it.

The os._exit is deliberate and stays: some builds with native extensions
intermittently SIGSEGV during teardown after an otherwise clean shutdown,
which is why _exit_as_main_process exists. But that reasoning applies to the
real process exit, not to a function under test. Adds _terminate(), which
raises SystemExit when PYTEST_CURRENT_TEST is set and calls os._exit
otherwise, and routes the three in-process exit paths through it.

This restores a contract the tests already assumed:
test_auto_sync_triggers_post asserts `pytest.raises(SystemExit)`. It was
written when display_menu raised, and the later switch to os._exit did not
fail that test -- it killed the runner instead, which is why nobody noticed.

The suite now runs to completion: 1160 passed, 15 failed, 16 skipped, and it
exits 1 rather than claiming success.

Those 15 were always failing; they were simply never reached. Five of them
were mine, and this is the uncomfortable part: the gen_version argument
added in 2aed95a broke more FakePasswordGenerator doubles than I found,
because the earlier regression run stopped before reaching them and I
concluded "no new failures" from a truncated result. All 20 remaining
doubles now take **_, so they absorb gen_version and anything added later
rather than needing a sweep each time the real signature grows.

The other 10 are pre-existing and unrelated -- legacy-migration and
checksum-backup failures, an index0.py int-parsing bug
(`invalid literal for int() with base 10: 'temp'`), and one that needs a TTY
this environment lacks.

Determinism gate still green.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01HtNMsKzzFTPURemX7tT19u
This commit is contained in:
thePR0M3TH3ANandClaude Opus 5 committed 2026-07-31 22:31:19 -04:00
1 parent 3192c9f306
commit 9e0f045ccb
16 files changed
+44 -23

No files matched your search

+6 -6
View File
@@ -218,7 +218,7 @@ def test_agent_get_password_json(monkeypatch):
def retrieve_entry(self, _i):
return {"type": EntryType.PASSWORD.value, "label": "Example", "length": 12}
def generate_password(self, _length, _index):
def generate_password(self, _length, _index, **_):
return "secret-pass"
monkeypatch.setattr(agent_cli, "EntryService", DummyEntryService)
@@ -464,7 +464,7 @@ def test_agent_get_safe_output_masks_by_default(monkeypatch):
def retrieve_entry(self, _i):
return {"type": EntryType.PASSWORD.value, "label": "Example", "length": 12}
def generate_password(self, _length, _index):
def generate_password(self, _length, _index, **_):
return "secret-pass"
monkeypatch.setattr(agent_cli, "EntryService", DummyEntryService)
@@ -510,7 +510,7 @@ def test_agent_token_issue_and_use_limit(monkeypatch, tmp_path):
def retrieve_entry(self, _i):
return {"type": EntryType.PASSWORD.value, "label": "Example", "length": 12}
def generate_password(self, _length, _index):
def generate_password(self, _length, _index, **_):
return "secret-pass"
monkeypatch.setattr(agent_cli, "EntryService", DummyEntryService)
@@ -860,7 +860,7 @@ def test_agent_token_denied_when_identity_revoked(monkeypatch, tmp_path):
def retrieve_entry(self, _i):
return {"type": EntryType.PASSWORD.value, "label": "Example", "length": 12}
def generate_password(self, _length, _index):
def generate_password(self, _length, _index, **_):
return "secret-pass"
monkeypatch.setattr(agent_cli, "EntryService", DummyEntryService)
@@ -948,7 +948,7 @@ def test_agent_token_denied_when_identity_missing(monkeypatch, tmp_path):
def retrieve_entry(self, _i):
return {"type": EntryType.PASSWORD.value, "label": "Example", "length": 12}
def generate_password(self, _length, _index):
def generate_password(self, _length, _index, **_):
return "secret-pass"
monkeypatch.setattr(agent_cli, "EntryService", DummyEntryService)
@@ -1598,7 +1598,7 @@ def test_agent_get_keyring_defaults_account_to_fingerprint(monkeypatch):
def retrieve_entry(self, _i):
return {"type": EntryType.PASSWORD.value, "label": "Example", "length": 12}
def generate_password(self, _length, _index):
def generate_password(self, _length, _index, **_):
return "secret-pass"
monkeypatch.setattr(agent_cli, "EntryService", DummyEntryService)