
self = <test_flywheel_eval.TestPerDayEvalBugPlan object at 0x11b04c0e0>
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x11b1b0e60>

    def test_range_uses_only_trading_days_and_is_idempotent_shape(self, monkeypatch):
        filed = []
    
        def fake_file_bug(*args, **kwargs):
            filed.append((args, kwargs))
            return {"fingerprint": f"fp-{kwargs['pattern']}", "created": True}
    
        monkeypatch.setattr(FE.BL, "file_bug", fake_file_bug)
        monkeypatch.setattr(FE.BL, "set_context", lambda *args, **kwargs: None)
        monkeypatch.setattr(
            "rtrader.scheduler.get_trading_days_between",
            lambda start_date, end_date: [date(2026, 7, 2), date(2026, 7, 6)],
        )
    
        plan = FE.file_per_day_eval_bugs(
            start=date(2026, 7, 2), end=date(2026, 7, 6),
            branch="9d948937ae", run_id="anchor-1", actor="test",
        )
    
        assert plan["count"] == 2
        assert [row["day"] for row in plan["days"]] == ["2026-07-02", "2026-07-06"]
        assert all("--date" in row["command"] and "--branch 9d948937ae" in row["command"]
                   for row in plan["days"])
        assert all(call[1]["requires_coding"] is False and call[1]["kind"] == "ops"
                   for call in filed)
>       assert all("anchor-1" in call[1]["context"] for call in filed)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

tests/services/test_flywheel_eval.py:289: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

.0 = <list_iterator object at 0x11b1ad0f0>

>   assert all("anchor-1" in call[1]["context"] for call in filed)
                             ^^^^^^^^^^^^^^^^^^
E   KeyError: 'context'

tests/services/test_flywheel_eval.py:289: KeyError
