File: test_types.py

package info (click to toggle)
sentry-python 2.18.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,004 kB
  • sloc: python: 55,908; makefile: 114; sh: 111; xml: 2
file content (28 lines) | stat: -rw-r--r-- 760 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
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