| 1 |
from __future__ import annotations |
| 2 |
|
| 3 |
from importlib.util import find_spec |
| 4 |
from typing import TYPE_CHECKING |
| 5 |
|
| 6 |
import pytest |
| 7 |
|
| 8 |
if TYPE_CHECKING: |
| 9 |
import zoneinfo |
| 10 |
|
| 11 |
import babel |
| 12 |
|
| 13 |
if not (find_spec("pytest_benchmark") or find_spec("pytest_codspeed")): |
| 14 |
pytest.skip("pytest-benchmark or pytest-codspeed required", allow_module_level=True) |
| 15 |
|
| 16 |
|
| 17 |
@pytest.fixture(scope="function", params=["fresh", "cached"]) |
| 18 |
def fi_locale(request) -> str | babel.Locale: |
| 19 |
from babel import Locale |
| 20 |
|
| 21 |
if request.param == "fresh": |
| 22 |
return "fi" |
| 23 |
return Locale.parse("fi") # Share the object in the test |
| 24 |
|
| 25 |
|
| 26 |
@pytest.fixture(scope="session") |
| 27 |
def helsinki_tz() -> zoneinfo.ZoneInfo: |
| 28 |
import zoneinfo |
| 29 |
|
| 30 |
return zoneinfo.ZoneInfo("Europe/Helsinki") |