mirror of
https://github.com/cssgunc/compass.git
synced 2025-04-09 14:00:15 -04:00
25 lines
574 B
Python
25 lines
574 B
Python
"""Shared pytest fixtures for database dependent tests."""
|
|
|
|
import pytest
|
|
from sqlalchemy import Engine
|
|
from sqlalchemy.orm import Session
|
|
|
|
from ...database import db_session
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def test_engine() -> Engine:
|
|
session = db_session()
|
|
return session
|
|
|
|
|
|
@pytest.fixture(scope="function")
|
|
def session(test_engine: Engine):
|
|
# entities.EntityBase.metadata.drop_all(test_engine)
|
|
# entities.EntityBase.metadata.create_all(test_engine)
|
|
session = Session(test_engine)
|
|
try:
|
|
yield session
|
|
finally:
|
|
session.close()
|