fix(M05): ensure config exists so opts.data populated for test_opts_override

When opts.load() gets FileNotFoundError, opts.data = {}.
temporary_opts only applies overrides for keys in opts.data.
Initialize fixture now creates minimal config.json when missing.

Made-with: Cursor
This commit is contained in:
Michael Cahill 2026-03-09 15:33:11 -07:00
parent 6fd992ae27
commit 3039abb1a0
2 changed files with 30 additions and 1 deletions

View file

@ -162,4 +162,21 @@ No failures. All jobs passed.
|-------|--------|--------|
| Smoke Tests | 22876253113 | ✓ success |
| Linter | 22876253091 | ✓ success |
| Quality Tests | — | Pending (push to main) |
| Quality Tests | 22877674534 | ✗ failed (test_opts_override) |
---
## 11. Quality Run 1 — Post-Merge (22877674534)
**Status:** Failed
**Cause:** `test_opts_override.py` — 2 failures
### Failure
When `opts.load()` gets `FileNotFoundError` (no config.json), it sets `opts.data = {}`.
`temporary_opts` only applies overrides for keys in `opts.data`, so no overrides are applied and `samples_save` stays at its default (True).
### Fix
Ensure a minimal config exists before loading webui so `opts.data` is populated.
Updated `test/conftest.py` `initialize` fixture to create `config.json` with `{"samples_save": True}` when missing.

View file

@ -45,4 +45,16 @@ def mask_basic_image_base64() -> str:
@pytest.fixture(scope="session")
def initialize() -> None:
"""Load webui; ensure config exists so opts.data is populated for quality tests."""
import json
import os
from modules.shared_cmd_options import cmd_opts
config_path = cmd_opts.ui_settings_file
if not os.path.exists(config_path):
os.makedirs(os.path.dirname(config_path) or ".", exist_ok=True)
with open(config_path, "w", encoding="utf-8") as f:
json.dump({"samples_save": True}, f)
import webui # noqa: F401