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
|
import sys
import pytest
from sentry_sdk.types import Event, Hint
@pytest.mark.skipif(
sys.version_info < (3, 10),
reason="Type hinting with `|` is available in Python 3.10+",
)
def test_event_or_none_runtime():
"""
Ensures that the `Event` type's runtime value supports the `|` operation with `None`.
This test is needed to ensure that using an `Event | None` type hint (e.g. for
`before_send`'s return value) does not raise a TypeError at runtime.
"""
Event | None
@pytest.mark.skipif(
sys.version_info < (3, 10),
reason="Type hinting with `|` is available in Python 3.10+",
)
def test_hint_or_none_runtime():
"""
Analogue to `test_event_or_none_runtime`, but for the `Hint` type.
"""
Hint | None
|