summaryrefslogtreecommitdiff
path: root/tests/schema
diff options
context:
space:
mode:
authorlikecodingloveproblems <mamehdizadeh.official@gmail.com>2022-03-19 00:33:50 +0330
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-03-21 20:54:48 +0100
commit4b66a5e61780416d8d99e61193f93dc3351caf2c (patch)
treeeba5d320b1563456244339f96f5f56161c1d5bd1 /tests/schema
parent561761c6606cd0e8bafb5e86c487871deb6e04e1 (diff)
downloaddjango-4b66a5e61780416d8d99e61193f93dc3351caf2c.tar.gz
Fixed #33256 -- Fixed schema test failures when using --keepdb.
Diffstat (limited to 'tests/schema')
-rw-r--r--tests/schema/tests.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/tests/schema/tests.py b/tests/schema/tests.py
index b47c720064..076663e049 100644
--- a/tests/schema/tests.py
+++ b/tests/schema/tests.py
@@ -2317,6 +2317,8 @@ class SchemaTests(TransactionTestCase):
# This fails if the unique index name isn't quoted.
editor.alter_unique_together(TagUniqueRename, [], (("title", "slug2"),))
finally:
+ with connection.schema_editor() as editor:
+ editor.delete_model(TagUniqueRename)
TagUniqueRename._meta.db_table = old_table_name
@isolate_apps("schema")
@@ -2394,6 +2396,7 @@ class SchemaTests(TransactionTestCase):
def test_remove_field_unique_does_not_remove_meta_constraints(self):
with connection.schema_editor() as editor:
editor.create_model(AuthorWithUniqueName)
+ self.local_models = [AuthorWithUniqueName]
# Add the custom unique constraint
constraint = UniqueConstraint(fields=["name"], name="author_name_uniq")
custom_constraint_name = constraint.name
@@ -2526,6 +2529,7 @@ class SchemaTests(TransactionTestCase):
def test_remove_unique_together_does_not_remove_meta_constraints(self):
with connection.schema_editor() as editor:
editor.create_model(AuthorWithUniqueNameAndBirthday)
+ self.local_models = [AuthorWithUniqueNameAndBirthday]
# Add the custom unique constraint
constraint = UniqueConstraint(
fields=["name", "birthday"], name="author_name_birthday_uniq"
@@ -2924,6 +2928,7 @@ class SchemaTests(TransactionTestCase):
def test_remove_index_together_does_not_remove_meta_indexes(self):
with connection.schema_editor() as editor:
editor.create_model(AuthorWithIndexedNameAndBirthday)
+ self.local_models = [AuthorWithIndexedNameAndBirthday]
# Add the custom index
index = Index(fields=["name", "birthday"], name="author_name_birthday_idx")
custom_index_name = index.name
@@ -3062,6 +3067,7 @@ class SchemaTests(TransactionTestCase):
"""
with connection.schema_editor() as editor:
editor.create_model(AuthorWithIndexedName)
+ self.local_models = [AuthorWithIndexedName]
# Ensure the table has its index
self.assertIn("name", self.get_indexes(AuthorWithIndexedName._meta.db_table))
@@ -3650,6 +3656,7 @@ class SchemaTests(TransactionTestCase):
with connection.schema_editor() as editor:
editor.create_model(Author)
editor.create_model(Book)
+ self.isolated_local_models = [Author]
if connection.vendor == "mysql":
self.assertForeignKeyExists(
Book, "author_id", '"table_author_double_quoted"'
@@ -3660,6 +3667,7 @@ class SchemaTests(TransactionTestCase):
def test_add_foreign_object(self):
with connection.schema_editor() as editor:
editor.create_model(BookForeignObj)
+ self.local_models = [BookForeignObj]
new_field = ForeignObject(
Author, on_delete=CASCADE, from_fields=["author_id"], to_fields=["id"]
@@ -4338,7 +4346,7 @@ class SchemaTests(TransactionTestCase):
apps = new_apps
db_table = '"%s"."DJANGO_DOCUMENT_TABLE"' % oracle_user
- self.local_models = [Student, Document]
+ self.isolated_local_models = [Student, Document]
with connection.schema_editor() as editor:
editor.create_model(Student)