views:

88

answers:

1

Are there database testing tools for python (like sqlunit)? I want to test the DAL that is built using sqlalchemy

+2  A: 

Follow the design pattern that Django uses.

  1. Create a disposable copy of the database. Use SQLite3 in-memory, for example.

  2. Create the database using the SQLAlchemy table and index definitions. This should be a fairly trivial exercise.

  3. Load the test data fixture into the database.

  4. Run your unit test case in a database with a known, defined state.

  5. Dispose of the database.

If you use SQLite3 in-memory, this procedure can be reasonably fast.

S.Lott