LibBotUniversal/tests/conftest.py

39 lines
882 B
Python
Raw Normal View History

2024-05-26 16:40:29 +03:00
from json import dumps, loads
from os import makedirs
2023-08-06 20:11:16 +03:00
from pathlib import Path
2024-05-26 16:40:29 +03:00
from uuid import uuid4
2023-08-06 20:11:16 +03:00
import pytest
from libbot.i18n import BotLocale
@pytest.fixture()
def location_config() -> Path:
2024-05-26 16:40:29 +03:00
makedirs(Path("tests/.tmp"), exist_ok=True)
filename = str(uuid4())
with open(Path("tests/config.json"), "r", encoding="utf-8") as file:
config = loads(file.read())
with open(Path(f"tests/.tmp/{filename}.json"), "w", encoding="utf-8") as file:
file.write(
dumps(
config,
ensure_ascii=False,
indent=4,
)
)
return Path(f"tests/.tmp/{filename}.json")
2023-08-06 20:11:16 +03:00
@pytest.fixture()
def location_locale() -> Path:
return Path("tests/data/locale/")
@pytest.fixture()
def bot_locale(location_locale: Path) -> BotLocale:
return BotLocale(locales_root=location_locale)