summaryrefslogtreecommitdiff
path: root/tests/indexes
diff options
context:
space:
mode:
authorDavid Wobrock <david.wobrock@gmail.com>2022-06-02 21:03:00 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-06-03 06:32:11 +0200
commita3a1290d47326c3f87824b3cf7ca969cb0d364aa (patch)
tree0956d8cf901c00e29c3ea1e626e10d15438769ae /tests/indexes
parent61badf1d58e79b84874afa6a1e00b79f20e786d1 (diff)
downloaddjango-a3a1290d47326c3f87824b3cf7ca969cb0d364aa.tar.gz
Refs #27236 -- Moved models with Meta.index_together inside of test methods.
Diffstat (limited to 'tests/indexes')
-rw-r--r--tests/indexes/models.py9
-rw-r--r--tests/indexes/tests.py28
2 files changed, 19 insertions, 18 deletions
diff --git a/tests/indexes/models.py b/tests/indexes/models.py
index 241556ca69..f7fcb6175c 100644
--- a/tests/indexes/models.py
+++ b/tests/indexes/models.py
@@ -43,15 +43,6 @@ class Article(models.Model):
]
-# Model for index_together being used only with single list
-class IndexTogetherSingleList(models.Model):
- headline = models.CharField(max_length=100)
- pub_date = models.DateTimeField()
-
- class Meta:
- index_together = ["headline", "pub_date"]
-
-
class IndexedArticle(models.Model):
headline = models.CharField(max_length=100, db_index=True)
body = models.TextField(db_index=True)
diff --git a/tests/indexes/tests.py b/tests/indexes/tests.py
index a752c3ac54..11f72850f3 100644
--- a/tests/indexes/tests.py
+++ b/tests/indexes/tests.py
@@ -3,7 +3,15 @@ from unittest import skipUnless
from django.conf import settings
from django.db import connection
-from django.db.models import CASCADE, ForeignKey, Index, Q
+from django.db.models import (
+ CASCADE,
+ CharField,
+ DateTimeField,
+ ForeignKey,
+ Index,
+ Model,
+ Q,
+)
from django.db.models.functions import Lower
from django.test import (
TestCase,
@@ -11,15 +19,10 @@ from django.test import (
skipIfDBFeature,
skipUnlessDBFeature,
)
-from django.test.utils import override_settings
+from django.test.utils import isolate_apps, override_settings
from django.utils import timezone
-from .models import (
- Article,
- ArticleTranslation,
- IndexedArticle2,
- IndexTogetherSingleList,
-)
+from .models import Article, ArticleTranslation, IndexedArticle2
class SchemaIndexesTests(TestCase):
@@ -79,8 +82,15 @@ class SchemaIndexesTests(TestCase):
index_sql[0],
)
+ @isolate_apps("indexes")
def test_index_together_single_list(self):
- # Test for using index_together with a single list (#22172)
+ class IndexTogetherSingleList(Model):
+ headline = CharField(max_length=100)
+ pub_date = DateTimeField()
+
+ class Meta:
+ index_together = ["headline", "pub_date"]
+
index_sql = connection.schema_editor()._model_indexes_sql(
IndexTogetherSingleList
)