summaryrefslogtreecommitdiff
path: root/tests/model_options
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2018-12-07 19:55:47 -0500
committerSimon Charette <charette.s@gmail.com>2018-12-15 18:51:59 -0500
commit315357ad25a6590e7f4564ec2e56a22132b09001 (patch)
tree64b14122ecf5f5fa9f48802b4edae27cd81733f6 /tests/model_options
parenta394289b58b1773c4959ed768fdb325c91b2b589 (diff)
downloaddjango-315357ad25a6590e7f4564ec2e56a22132b09001.tar.gz
Fixed #30023 -- Prevented SQLite schema alterations while foreign key checks are enabled.
Prior to this change foreign key constraint references could be left pointing at tables dropped during operations simulating unsupported table alterations because of an unexpected failure to disable foreign key constraint checks. SQLite3 does not allow disabling such checks while in a transaction so they must be disabled beforehand. Thanks ezaquarii for the report and Carlton and Tim for the review.
Diffstat (limited to 'tests/model_options')
-rw-r--r--tests/model_options/test_tablespaces.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/tests/model_options/test_tablespaces.py b/tests/model_options/test_tablespaces.py
index 79b0a8bb75..8502d8790f 100644
--- a/tests/model_options/test_tablespaces.py
+++ b/tests/model_options/test_tablespaces.py
@@ -1,7 +1,9 @@
from django.apps import apps
from django.conf import settings
from django.db import connection
-from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature
+from django.test import (
+ TransactionTestCase, skipIfDBFeature, skipUnlessDBFeature,
+)
from .models.tablespaces import (
Article, ArticleRef, Authors, Reviewers, Scientist, ScientistRef,
@@ -21,7 +23,8 @@ def sql_for_index(model):
# We can't test the DEFAULT_TABLESPACE and DEFAULT_INDEX_TABLESPACE settings
# because they're evaluated when the model class is defined. As a consequence,
# @override_settings doesn't work, and the tests depend
-class TablespacesTests(TestCase):
+class TablespacesTests(TransactionTestCase):
+ available_apps = ['model_options']
def setUp(self):
# The unmanaged models need to be removed after the test in order to