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
Post a Comment