diff --git a/test/fixtures.py b/test/fixtures.py index 3822d28f3..e442234b8 100644 --- a/test/fixtures.py +++ b/test/fixtures.py @@ -135,6 +135,7 @@ def appconfig(database_uri): @pytest.fixture() def initialized_db(appconfig): """ Configures the database for the database found in the appconfig. """ + under_test_real_database = bool(os.environ.get('TEST_DATABASE_URI')) # Configure the database. configure(appconfig) @@ -144,8 +145,12 @@ def initialized_db(appconfig): model._basequery.get_public_repo_visibility() model.log.get_log_entry_kinds() + if not under_test_real_database: + # Make absolutely sure foreign key constraints are on. + db.obj.execute_sql('PRAGMA foreign_keys = ON;') + assert db.obj.execute_sql('PRAGMA foreign_keys;').fetchone()[0] == 1 + # If under a test *real* database, setup a savepoint. - under_test_real_database = bool(os.environ.get('TEST_DATABASE_URI')) if under_test_real_database: with db.transaction(): test_savepoint = db.savepoint()