test(tools): extend the delegation fd-leak injection to the schema replay
The schema initializer now replays SCHEMA_SQL through executescript (the single-authority path from #94701's follow-up), which bypasses the execute()-level DDL failure injection — the regression stopped raising. Bind the same simulated failure onto the executescript path so the connect-close-on-init-failure contract stays pinned for both replay mechanisms.
This commit is contained in:
@@ -79,6 +79,16 @@ def test_ledger_operations_close_every_connection(monkeypatch, tmp_path):
|
||||
assert set(opened) == set(closed)
|
||||
|
||||
|
||||
def _fail_large_schema_replay(self, script):
|
||||
# The schema initializer replays the full canonical schema as one
|
||||
# large multi-statement script (single durable-shape authority,
|
||||
# #94691). Simulate the DDL failure on that path so the
|
||||
# connect-close-on-init-failure contract stays pinned.
|
||||
if len(script) > 1000:
|
||||
raise sqlite3.OperationalError("simulated schema init failure")
|
||||
return self._real.executescript(script)
|
||||
|
||||
|
||||
def test_schema_init_failure_still_closes_connection(monkeypatch, tmp_path):
|
||||
"""A PRAGMA/DDL failure after connect() must still close the connection."""
|
||||
_point_ledger(monkeypatch, tmp_path)
|
||||
@@ -98,6 +108,8 @@ def test_schema_init_failure_still_closes_connection(monkeypatch, tmp_path):
|
||||
|
||||
monkeypatch.setattr(ad.sqlite3, "connect", tracking_connect)
|
||||
|
||||
_FailingSchemaConnection.executescript = _fail_large_schema_replay
|
||||
|
||||
with pytest.raises(sqlite3.OperationalError):
|
||||
with ad._transaction():
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user