mirror of
https://github.com/TauricResearch/TradingAgents.git
synced 2026-11-22 17:19:56 +02:00
fix(backtest): give each sweep started without a run_id its own run (#1549)
- the stamped run directory is claimed atomically; a second sweep in the same second takes the next suffix instead of resuming the first
This commit is contained in:
@@ -155,6 +155,23 @@ def test_the_analyst_set_under_test_is_the_one_that_runs(tmp_path):
|
||||
assert _FakeGraph.instances[-1].analysts == ["market", "news"]
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_sweeps_started_in_the_same_second_get_their_own_runs(tmp_path, monkeypatch):
|
||||
import tradingagents.backtest as backtest
|
||||
|
||||
class _Frozen(backtest.datetime):
|
||||
@classmethod
|
||||
def now(cls, tz=None):
|
||||
return cls(2026, 1, 20, 9, 30, 0)
|
||||
|
||||
monkeypatch.setattr(backtest, "datetime", _Frozen)
|
||||
first = run_backtest(["NVDA"], ["2026-01-05"], _config(tmp_path))
|
||||
second = run_backtest(["NVDA"], ["2026-01-05"], _config(tmp_path))
|
||||
|
||||
assert first.run_id == "20260120_093000" and second.run_id == "20260120_093000_2"
|
||||
assert first.cells_run == second.cells_run == 1
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_a_run_id_cannot_escape_the_results_directory(tmp_path):
|
||||
"""run_id becomes a path segment, so it is validated like a ticker is."""
|
||||
|
||||
Reference in New Issue
Block a user