"""An optional HTML copy of the report, for readers who do not open Markdown (#1419). It is one self-contained file: no script, no remote asset, nothing a report's text can inject; the Markdown report is unchanged. """ import re import pytest from tradingagents.reporting import write_report_tree SETTINGS = {"version": "1.2.3", "llm_provider": "openai", "deep_think_llm": "gpt-6-sol", "quick_think_llm": "gpt-6-luna", "analysts": ["market", "news"], "max_debate_rounds": 1, "max_risk_discuss_rounds": 1, "data_vendors": {"core_stock_apis": "yfinance"}} def _state(**overrides): state = {"trade_date": "2026-09-26", "market_report": "# Market view\n\nPrice | Level\n--- | ---\nClose | 181.2\n", "news_report": "News text.", "final_trade_decision": "**Rating**: Overweight\n\nAdd on weakness."} state.update(overrides) return state def _html(tmp_path, **overrides): write_report_tree(_state(**overrides), "NVDA", tmp_path, settings=SETTINGS, html=True) return (tmp_path / "complete_report.html").read_text(encoding="utf-8") @pytest.mark.unit def test_the_html_page_is_written_unless_declined(tmp_path): write_report_tree(_state(), "NVDA", tmp_path / "plain", settings=SETTINGS, html=False) assert not (tmp_path / "plain" / "complete_report.html").exists() write_report_tree(_state(), "NVDA", tmp_path / "default", settings=SETTINGS) assert (tmp_path / "default" / "complete_report.html").exists() page = _html(tmp_path / "html") assert "