12.8.2. crate_anon.testing.classes
crate_anon/testing/classes.py
Copyright (C) 2015, University of Cambridge, Department of Psychiatry. Created by Rudolf Cardinal (rnc1001@cam.ac.uk).
This file is part of CRATE.
CRATE is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
CRATE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with CRATE. If not, see <https://www.gnu.org/licenses/>.
Test classes for more complex tests e.g. where a database session is required.
- class crate_anon.testing.classes.CommonDatabaseTestCase(methodName='runTest')[source]
Base class for testing with a database. Do not inherit from this directly, use one of the below subclasses instead, which will be associated with pytest fixtures for engine, session etc.
- class crate_anon.testing.classes.DatabaseTestCase(methodName='runTest')[source]
Base class for testing with a database.
The pytest fixtures defined in conftest.py run each test in a transaction, rolling back the transaction at the end of the test. This all works fine, unless one of the tests encounters a DatabaseError and the transaction needs to be rolled back. In this case we need the approach taken by SlowSecretDatabaseTestCase below.