from json import dumps, loads from os import makedirs from pathlib import Path from uuid import uuid4 import pytest from libbot.i18n import BotLocale @pytest.fixture() def location_config() -> Path: 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") @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)