| 1 |
from __future__ import annotations |
| 2 |
|
| 3 |
import sys |
| 4 |
import typing as t |
| 5 |
from types import ModuleType |
| 6 |
|
| 7 |
import pytest |
| 8 |
|
| 9 |
import markupsafe |
| 10 |
from markupsafe import _native |
| 11 |
|
| 12 |
try: |
| 13 |
from markupsafe import _speedups |
| 14 |
except ImportError: |
| 15 |
_speedups = None # type: ignore |
| 16 |
|
| 17 |
|
| 18 |
def pytest_report_header() -> list[str]: |
| 19 |
"""Return a list of strings to be displayed in the header of the report.""" |
| 20 |
if sys.version_info >= (3, 13): |
| 21 |
return [f"Free-threaded: {not sys._is_gil_enabled()}"] |
| 22 |
|
| 23 |
return [] |
| 24 |
|
| 25 |
|
| 26 |
@pytest.fixture( |
| 27 |
scope="session", |
| 28 |
autouse=True, |
| 29 |
params=( |
| 30 |
_native, |
| 31 |
pytest.param( |
| 32 |
_speedups, |
| 33 |
marks=pytest.mark.skipif(_speedups is None, reason="speedups unavailable"), |
| 34 |
), |
| 35 |
), |
| 36 |
) |
| 37 |
def _mod(request: pytest.FixtureRequest) -> None: |
| 38 |
mod = t.cast(ModuleType, request.param) |
| 39 |
markupsafe._escape_inner = mod._escape_inner # type: ignore[attr-defined] |