python - Rolling back database transactions in SQLAlchemy tests with PostgreSQL -



python - Rolling back database transactions in SQLAlchemy tests with PostgreSQL -

i building pyramid web application built on top of sqlalchemy , solely relies postgresql database backend.

what way have unit tests construction that

to speed tests, database transactions rolled @ teardown(), or other clean hook of test suite

other tricks speed tests used, e.g. if sqlalchemy , postgresql has corresponding sqlite's :in:memory: database

it possible take custom test runner รก la py.test if specific features outside standard library unittest framework makes easier write test cases.

since question bit similar other question, i'll re-create relevant part of reply here:

all test case classes should subclassed base of operations class, defines mutual teardown method:

class basetest(unittest.testcase): def setup(self): # makes things nicer if previous test fails # - without subsequent tests fail self.teardown() self.config = testing.setup() def teardown(self): testing.teardown() session.expunge_all() session.rollback()

python postgresql sqlalchemy pyramid

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -