File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ from os import getenv
2+ from pathlib import Path
3+
4+
5+ def sqla_uri ():
6+ testing_db_url = getenv ("TESTING_DB_URL" )
7+ if not testing_db_url :
8+ db_dir = Path (__file__ ).resolve ().parent
9+ testing_db_url = f"sqlite+aiosqlite:///{ db_dir } /db.sqlite3"
10+ return testing_db_url
Original file line number Diff line number Diff line change 1- from pathlib import Path
2-
31from pytest import fixture # noqa PT013
42from pytest_asyncio import fixture as async_fixture
53from sqlalchemy .engine import make_url
64from sqlalchemy .ext .asyncio import AsyncSession , create_async_engine
75from sqlalchemy .orm import sessionmaker
86
7+ from tests .common import sqla_uri
98from tests .models import Base
109
1110
12- def sqla_uri ():
13- db_dir = Path (__file__ ).resolve ().parent .parent
14- return f"sqlite+aiosqlite:///{ db_dir } /db.sqlite3"
15-
16-
1711def get_async_sessionmaker () -> sessionmaker :
1812 engine = create_async_engine (url = make_url (sqla_uri ()))
1913 _async_session = sessionmaker (bind = engine , class_ = AsyncSession , expire_on_commit = False )
You can’t perform that action at this time.
0 commit comments