Skip to content

Flask-SQLAlchemy example repo for configuring database rollbacks per test

License

Notifications You must be signed in to change notification settings

gmassman/fsa-rollback-per-test-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flask-SQLAlchemy Rollback per Test Example

This repository shows a minimal working example of a Flask-SQLAlchemy application with pytest setup. Most notably, tests are isolated using database transactions that can be rolled back after each test ends. This allows each test to start with a clean test database. The example here works with PostgreSQL, but the pattern should be applicable to all databases SQLAlchemy 2.x supports.

Setup

python -m venv .venv
source .venv/bin/activate
pipenv install --dev --ignore-pipfile
initdb fsa_rollback_per_test
pytest

About

Flask-SQLAlchemy example repo for configuring database rollbacks per test

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages