File: hooks.py

package info (click to toggle)
python-pytest-retry 1.6.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 208 kB
  • sloc: python: 658; makefile: 3
file content (35 lines) | stat: -rw-r--r-- 1,187 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import pytest


@pytest.hookspec(firstresult=True)
def pytest_set_filtered_exceptions() -> None:
    """
    Return a collection of exception classes to be used as a filter when retrying tests.

    This pytest hook is called during setup to gather a collection of exception classes.
    Only tests that fail with one of the listed exceptions will be retried (individual flaky
    marks which specify their own exceptions will override this list).

    Example:
        # In your conftest.py file:
        def pytest_set_filtered_exceptions():
            return (CustomError, ValueError)
    """
    ...


@pytest.hookspec(firstresult=True)
def pytest_set_excluded_exceptions() -> None:
    """
    Return a collection of exception classes to be excluded when retrying tests.

    This pytest hook is called during setup to gather a collection of exception classes.
    Tests that fail with one of the listed exceptions will NOT be retried (individual flaky
    marks which specify their own exceptions will override this list).

    Example:
        # In your conftest.py file:
        def pytest_set_filtered_exceptions():
            return (CustomError, ValueError)
    """
    ...