-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
31 lines (21 loc) · 800 Bytes
/
conftest.py
File metadata and controls
31 lines (21 loc) · 800 Bytes
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
import os
import pytest
from db_learning.root_module import ApplicationModule
from ellar.common.constants import ELLAR_CONFIG_MODULE
from ellar.testing import Test
from ellar.threading.sync_worker import execute_async_context_manager
from ellar_sql import EllarSQLService
os.environ.setdefault(ELLAR_CONFIG_MODULE, "db_learning.config:TestConfig")
@pytest.fixture(scope="session")
def tm():
test_module = Test.create_test_module(modules=[ApplicationModule])
app = test_module.create_application()
with execute_async_context_manager(app.with_injector_context()):
yield test_module
@pytest.fixture(scope="session")
def db(tm):
db_service = tm.get(EllarSQLService)
db_service.create_all()
yield
db_service.session_factory.remove()
db_service.drop_all()