-
Notifications
You must be signed in to change notification settings - Fork 453
/
Copy pathconftest.py
39 lines (33 loc) · 1.02 KB
/
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
import pytest
try:
import zoneinfo
except ModuleNotFoundError:
try:
from backports import zoneinfo
except ImportError:
zoneinfo = None
try:
import pytz
except ModuleNotFoundError:
pytz = None
def pytest_generate_tests(metafunc):
if hasattr(metafunc.function, "pytestmark"):
for mark in metafunc.function.pytestmark:
if mark.name == "all_locales":
from babel.localedata import locale_identifiers
metafunc.parametrize("locale", list(locale_identifiers()))
break
@pytest.fixture(params=["pytz.timezone", "zoneinfo.ZoneInfo"], scope="package")
def timezone_getter(request):
if request.param == "pytz.timezone":
if pytz:
return pytz.timezone
else:
pytest.skip("pytz not available")
elif request.param == "zoneinfo.ZoneInfo":
if zoneinfo:
return zoneinfo.ZoneInfo
else:
pytest.skip("zoneinfo not available")
else:
raise NotImplementedError