-
Notifications
You must be signed in to change notification settings - Fork 2
/
conftest.py
45 lines (35 loc) · 1001 Bytes
/
conftest.py
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
36
37
38
39
40
41
42
43
44
45
"""
Setup for Sybil.
"""
from doctest import ELLIPSIS
import pytest
from beartype import beartype
from sybil import Sybil
from sybil.parsers.rest import (
DocTestParser,
PythonCodeBlockParser,
)
from tests.mock_vws.utils.retries import RETRY_EXCEPTIONS
@beartype
def pytest_collection_modifyitems(items: list[pytest.Item]) -> None:
"""
Apply the beartype decorator to all collected test functions.
"""
for item in items:
if isinstance(item, pytest.Function):
item.obj = beartype(obj=item.obj)
pytest_collect_file = Sybil(
parsers=[
DocTestParser(optionflags=ELLIPSIS),
PythonCodeBlockParser(),
],
patterns=["*.rst", "*.py"],
).pytest()
@beartype
@pytest.hookimpl(optionalhook=True)
def pytest_set_filtered_exceptions() -> tuple[type[Exception], ...]:
"""Return exceptions to retry on.
This is for ``pytest-retry``.
The configuration for retries is in ``pyproject.toml``.
"""
return RETRY_EXCEPTIONS