Skip to content

Instantly share code, notes, and snippets.

View keithfma's full-sized avatar

Keith Ma keithfma

View GitHub Profile
@kissgyorgy
kissgyorgy / sqlalchemy_conftest.py
Last active May 3, 2024 07:21
Python: py.test fixture for SQLAlchemy test in a transaction, create tables only once!
from sqlalchemy import create_engine
from sqlalchemy.orm import Session
from myapp.models import BaseModel
import pytest
@pytest.fixture(scope="session")
def engine():
return create_engine("postgresql://localhost/test_database")