MCPcopy Create free account
hub / github.com/anthropics/anthropic-sdk-python / count_accumulated_events

Function count_accumulated_events

tests/test_open_telemetry.py:820–833  ·  view source on GitHub ↗

Wraps the stable or the beta `accumulate_event`, which the stream helpers and the spans share, so that the type of each event it takes is added to the list returned.

(monkeypatch: pytest.MonkeyPatch, *, beta: bool)

Source from the content-addressed store, hash-verified

818
819
820def count_accumulated_events(monkeypatch: pytest.MonkeyPatch, *, beta: bool) -> list[str]:
821 """Wraps the stable or the beta `accumulate_event`, which the stream helpers and the spans share, so that
822 the type of each event it takes is added to the list returned.
823 """
824 module = _beta_messages if beta else _messages
825 accumulate_event = module.accumulate_event
826 accumulated: list[str] = []
827
828 def counting(**kwargs: Any) -> Any:
829 accumulated.append(kwargs["event"].type)
830 return accumulate_event(**kwargs)
831
832 monkeypatch.setattr(module, "accumulate_event", counting)
833 return accumulated
834
835
836def events_up_to_message_delta() -> list[dict[str, Any]]:

Calls

no outgoing calls

Tested by

no test coverage detected