| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- import importlib.util
- import sys
- from pathlib import Path
- def load_module():
- path = Path(__file__).resolve().parents[1] / "scripts" / "search_long_short_fusion_with_calendar.py"
- spec = importlib.util.spec_from_file_location("search_long_short_fusion_with_calendar", path)
- assert spec is not None
- module = importlib.util.module_from_spec(spec)
- assert spec.loader is not None
- sys.modules[spec.name] = module
- spec.loader.exec_module(module)
- return module
- def test_report_text_handles_empty_selection():
- module = load_module()
- pandas = __import__("pandas")
- text = module.report_text("cmd", [], pandas.DataFrame(), pandas.DataFrame(), pandas.DataFrame())
- assert "No selected candidates" in text
- def test_empty_output_column_contracts_are_declared():
- module = load_module()
- assert module.HORIZON_COLUMNS == [
- "name",
- "kind",
- "horizon",
- "start",
- "end",
- "total_return",
- "annualized_return",
- "max_drawdown",
- "calmar",
- "improved_vs_no_calendar",
- "delta_total_return",
- "delta_calmar",
- "delta_max_drawdown",
- ]
- assert module.MONTHLY_COLUMNS == ["name", "kind", "month", "start_equity", "end_equity", "return"]
|