Skip to content

Commit

Permalink
Add to_dict method on StatsError
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Baldwin committed Oct 11, 2023
1 parent 2c281ff commit 6e25463
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions locust/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,14 @@ def _getattr(obj: "StatsError", key: str, default: Optional[Any]) -> Optional[An
def unserialize(cls, data: StatsErrorDict) -> "StatsError":
return cls(data["method"], data["name"], data["error"], data["occurrences"])

def to_dict(self, escape_string_values=False):
return {
"method": escape(self.method),
"name": escape(self.name),
"error": escape(self.parse_error(self.error)),
"occurrences": self.occurrences,
}


def avg(values: List[float | int]) -> float:
return sum(values, 0.0) / max(len(values), 1)
Expand Down

0 comments on commit 6e25463

Please sign in to comment.