24 lines
639 B
Python
24 lines
639 B
Python
from __future__ import annotations
|
|
|
|
import pytest
|
|
from sqlmodel import SQLModel, Session, create_engine
|
|
|
|
from aitbc_chain.models import Block, Transaction, Receipt # noqa: F401 - ensure models imported for metadata
|
|
|
|
|
|
@pytest.fixture(name="engine")
|
|
def engine_fixture():
|
|
engine = create_engine("sqlite:///:memory:", connect_args={"check_same_thread": False})
|
|
SQLModel.metadata.create_all(engine)
|
|
try:
|
|
yield engine
|
|
finally:
|
|
SQLModel.metadata.drop_all(engine)
|
|
|
|
|
|
@pytest.fixture(name="session")
|
|
def session_fixture(engine):
|
|
with Session(engine) as session:
|
|
yield session
|
|
session.rollback()
|