pythonunit-testingpostgresqlsqlalchemydata-access-layer

Database testing in python, postgresql


How do you unit test your python DAL that is using postgresql.

In sqlite you could create in-memory database for every test but this cannot be done for postgresql.

I want a library that could be used to setup a database and clean it once the test is done.

I am using Sqlalchemy as my ORM.


Solution

  • You can use nose to write your tests, then just use SQLAlchemy to create and clean the test database in your setup/teardown methods.