summaryrefslogtreecommitdiff
path: root/tests/postgres_tests
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2022-08-03 11:42:51 +0200
committerGitHub <noreply@github.com>2022-08-03 11:42:51 +0200
commitcb791a2540c289390b68a3ea9c6a79476890bab2 (patch)
treea09b63477f9fcce4e56636978236ef10c68ff891 /tests/postgres_tests
parent09e837c5d93d8ac22697e711901a63ead59c9fd4 (diff)
Fixed #33872 -- Deprecated django.contrib.postgres.fields.CIText/CICharField/CIEmailField/CITextField.
Diffstat (limited to 'tests/postgres_tests')
-rw-r--r--tests/postgres_tests/fields.py12
-rw-r--r--tests/postgres_tests/migrations/0002_create_test_models.py1
-rw-r--r--tests/postgres_tests/models.py1
-rw-r--r--tests/postgres_tests/test_citext.py9
4 files changed, 17 insertions, 6 deletions
diff --git a/tests/postgres_tests/fields.py b/tests/postgres_tests/fields.py
index 2d62e26a92..1565b5ed43 100644
--- a/tests/postgres_tests/fields.py
+++ b/tests/postgres_tests/fields.py
@@ -7,12 +7,12 @@ import enum
from django.db import models
try:
+ from django.contrib.postgres.fields import CICharField # RemovedInDjango51Warning.
+ from django.contrib.postgres.fields import CIEmailField # RemovedInDjango51Warning.
+ from django.contrib.postgres.fields import CITextField # RemovedInDjango51Warning.
from django.contrib.postgres.fields import (
ArrayField,
BigIntegerRangeField,
- CICharField,
- CIEmailField,
- CITextField,
DateRangeField,
DateTimeRangeField,
DecimalRangeField,
@@ -47,9 +47,9 @@ except ImportError:
ArrayField = DummyArrayField
BigIntegerRangeField = models.Field
- CICharField = models.Field
- CIEmailField = models.Field
- CITextField = models.Field
+ CICharField = models.Field # RemovedInDjango51Warning.
+ CIEmailField = models.Field # RemovedInDjango51Warning.
+ CITextField = models.Field # RemovedInDjango51Warning.
DateRangeField = models.Field
DateTimeRangeField = DummyContinuousRangeField
DecimalRangeField = DummyContinuousRangeField
diff --git a/tests/postgres_tests/migrations/0002_create_test_models.py b/tests/postgres_tests/migrations/0002_create_test_models.py
index 1b05435494..a1d9a942d0 100644
--- a/tests/postgres_tests/migrations/0002_create_test_models.py
+++ b/tests/postgres_tests/migrations/0002_create_test_models.py
@@ -291,6 +291,7 @@ class Migration(migrations.Migration):
options=None,
bases=None,
),
+ # RemovedInDjango51Warning.
migrations.CreateModel(
name="CITestModel",
fields=[
diff --git a/tests/postgres_tests/models.py b/tests/postgres_tests/models.py
index 8f27838ad5..05f2732fb8 100644
--- a/tests/postgres_tests/models.py
+++ b/tests/postgres_tests/models.py
@@ -119,6 +119,7 @@ class Character(models.Model):
name = models.CharField(max_length=255)
+# RemovedInDjango51Warning.
class CITestModel(PostgreSQLModel):
name = CICharField(primary_key=True, max_length=255)
email = CIEmailField()
diff --git a/tests/postgres_tests/test_citext.py b/tests/postgres_tests/test_citext.py
index f1c13184b6..314f2e40d3 100644
--- a/tests/postgres_tests/test_citext.py
+++ b/tests/postgres_tests/test_citext.py
@@ -1,3 +1,4 @@
+# RemovedInDjango51Warning.
"""
The citext PostgreSQL extension supports indexing of case-insensitive text
strings and thus eliminates the need for operations such as iexact and other
@@ -5,6 +6,7 @@ modifiers to enforce use of an index.
"""
from django.db import IntegrityError
from django.test.utils import modify_settings
+from django.utils.deprecation import RemovedInDjango51Warning
from . import PostgreSQLTestCase
from .models import CITestModel
@@ -82,3 +84,10 @@ class CITextTestCase(PostgreSQLTestCase):
self.assertSequenceEqual(
CITestModel.objects.filter(**query), [self.john]
)
+
+ def test_citext_deprecated(self):
+ from django.contrib.postgres.fields import CIText
+
+ msg = "django.contrib.postgres.fields.CIText mixin is deprecated."
+ with self.assertRaisesMessage(RemovedInDjango51Warning, msg):
+ CIText()