/
romaaaka
/
queuebot
Обзор
Документация
Войти
/
romaaaka
/
queuebot
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
1.1.0
src/tests/database/test.py
21 строка
574 B
Roman
add testing environment
17 июн 2024, 16:30
17 июн 2024, 16:30
a8d6e74
Код
Авторство
О чём код?
from functools import wraps from playhouse.sqlite_ext import SqliteExtDatabase def with_test_db(dbs: tuple): def decorator(func): @wraps(func) async def test_db_closure(*args, **kwargs): test_db = SqliteExtDatabase(":memory:") with test_db.bind_ctx(dbs): test_db.create_tables(dbs) try: await func(*args, **kwargs) finally: test_db.drop_tables(dbs) test_db.close() return test_db_closure return decorator