Skip to content

pytest-dev/pytest-sqlalchemy

Repository files navigation

pytest-sqlalchemy

Docs PyPI Git

SQLAlchemy related fixtures to handle connections and transactions with SQLAlchemy in tests.

Fixtures

This plugin provides the following fixtures which gives access to the SQLAlchemy objects of the same name.

  • engine The engine used to connect to the database. Scope is "module".
  • connection An open connection to the database. Scope is "module".

See Working with Engines and Connections on how to use these fixtures.

  • transaction A started transaction on the connection. Transaction will be rolled back. No Scope.

See Using Transactions on how to use this fixtures

  • dbsession A sqlalchemy session not bound to any model. No scope.

See Session Basics to learn about how to use sessions.

Usage

The fixtures can be used in your tests like any other