RetryStatsΒΆ

.. py:class:: RetryStats(total_retries: int = 0, scenarios_retried: list[~behave_retry.stats.ScenarioRetry] = ) :module: behave_retry :canonical: behave_retry.stats.RetryStats

Bases: :py:class:object

Aggregate retry statistics for a test run.

.. attribute:: total_retries

  Total number of retry attempts across all scenarios.

  :type: int

.. attribute:: scenarios_retried

  List of ``ScenarioRetry`` records.

  :type: list[behave_retry.stats.ScenarioRetry]

.. py:method:: RetryStats.add_retry(scenario: str, attempts: int, final_status: str, exceptions: list[str] | None = None, key: str | None = None) -> None :module: behave_retry

  Record a scenario that was retried.

  :param scenario: The name of the scenario.
  :param attempts: Total number of execution attempts.
  :param final_status: The final status: ``"passed"`` or ``"failed"``.
  :param exceptions: List of exception class names, or ``None``.
  :param key: Optional unique key for collision prevention.

.. py:property:: RetryStats.scenarios_failed_after_retry :module: behave_retry :type: int

  Count of scenarios that failed after exhausting all retries.

.. py:property:: RetryStats.scenarios_passed_on_retry :module: behave_retry :type: int

  Count of scenarios that passed after at least one retry.

.. py:attribute:: RetryStats.scenarios_retried :module: behave_retry :type: list[~behave_retry.stats.ScenarioRetry]

.. py:method:: RetryStats.summary() -> str :module: behave_retry

  Human-readable retry summary.

  :returns: A formatted multi-line string with retry statistics.

.. py:method:: RetryStats.to_dict() -> dict[str, object] :module: behave_retry

  Serialize to a dictionary for CI/CD reporting.

  :returns: A dictionary with total_retries, scenarios_retried,
            scenarios_passed_on_retry, and scenarios_failed_after_retry.

.. py:attribute:: RetryStats.total_retries :module: behave_retry :type: int :value: 0

.. py:method:: RetryStats.update_retry(scenario: str, attempts: int, final_status: str, exceptions: list[str] | None = None, key: str | None = None) -> None :module: behave_retry

  Update an existing retry record, or create a new one.

  If the scenario already exists in ``scenarios_retried`` (matched
  by ``key`` if provided, otherwise by ``scenario`` name), its
  attempts, final_status, and exceptions are updated in place
  and ``total_retries`` is adjusted accordingly. Otherwise, a
  new entry is created via ``add_retry``.

  :param scenario: The name of the scenario.
  :param attempts: Total number of execution attempts.
  :param final_status: The final status: ``"passed"`` or ``"failed"``.
  :param exceptions: List of exception class names, or ``None``.
  :param key: Optional unique key for collision prevention.