summaryrefslogtreecommitdiff
path: root/tests/invalid_models_tests
diff options
context:
space:
mode:
authorClifford Gama <cliffygamy@gmail.com>2025-05-16 23:48:38 +0200
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2025-06-18 08:36:49 +0200
commit74b31cd26b9ad4ad85f131850a734f02aae988bb (patch)
treeceabf0b4c985ae8159d44cf969e17c31bd38a337 /tests/invalid_models_tests
parent8c56e939750ae785b806dfa4e043590760c90ab6 (diff)
Fixed #32770 -- Added system check to ensure django.contrib.postgres is installed when using its features.
Added postgres.E005 to validate 'django.contrib.postgres' is in INSTALLED_APPS when using: * PostgreSQL-specific fields (ArrayField, HStoreField, range fields, SearchVectorField), * PostgreSQL indexes (PostgresIndex and all subclasses), and * ExclusionConstraint The check provides immediate feedback during system checks rather than failing later with obscure runtime and database errors. Thanks to Simon Charette and Sarah Boyce for reviews.
Diffstat (limited to 'tests/invalid_models_tests')
-rw-r--r--tests/invalid_models_tests/test_deprecated_fields.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/tests/invalid_models_tests/test_deprecated_fields.py b/tests/invalid_models_tests/test_deprecated_fields.py
index 65f65e7528..e3c7d2e12f 100644
--- a/tests/invalid_models_tests/test_deprecated_fields.py
+++ b/tests/invalid_models_tests/test_deprecated_fields.py
@@ -3,7 +3,7 @@ from unittest import skipUnless
from django.core import checks
from django.db import connection, models
from django.test import SimpleTestCase
-from django.test.utils import isolate_apps
+from django.test.utils import isolate_apps, modify_settings
@isolate_apps("invalid_models_tests")
@@ -87,6 +87,7 @@ class DeprecatedFieldsTests(SimpleTestCase):
)
@skipUnless(connection.vendor == "postgresql", "PostgreSQL specific SQL")
+ @modify_settings(INSTALLED_APPS={"append": "django.contrib.postgres"})
def test_postgres_ci_fields_deprecated(self):
from django.contrib.postgres.fields import (
ArrayField,