diff options
| author | David Sanders <shang.xiao.sanders@gmail.com> | 2023-09-24 19:02:50 +1000 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-09-25 09:14:05 +0200 |
| commit | 491092086929f90c048b606c58859f76238bcda2 (patch) | |
| tree | 00ab760f2446e1fb9df9ad93c4f75bc220c86003 /tests/postgres_tests | |
| parent | 81663cc4ca8f7ac0eac33cbb6986462330e75bb1 (diff) | |
[5.0.x] Fixed #34849 -- Avoided raising RuntimeWarning about import-time queries when apps are reinitialized with test tools.
Regression in fbd16438f46bc2128926958ad24331da5d1b406f.
Backport of 4f2ae0644de34791b84b7beb11a966ce4bc48fb6 from main
Diffstat (limited to 'tests/postgres_tests')
| -rw-r--r-- | tests/postgres_tests/test_apps.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/postgres_tests/test_apps.py b/tests/postgres_tests/test_apps.py index 3fdd7c3faf..ea2a28d7a8 100644 --- a/tests/postgres_tests/test_apps.py +++ b/tests/postgres_tests/test_apps.py @@ -5,7 +5,7 @@ from django.db import connection from django.db.backends.signals import connection_created from django.db.migrations.writer import MigrationWriter from django.test import TestCase -from django.test.utils import modify_settings +from django.test.utils import CaptureQueriesContext, modify_settings, override_settings try: from django.contrib.postgres.fields import ( @@ -14,6 +14,7 @@ try: DecimalRangeField, IntegerRangeField, ) + from django.contrib.postgres.signals import get_hstore_oids from django.db.backends.postgresql.psycopg_any import ( DateRange, DateTimeRange, @@ -27,6 +28,15 @@ except ImportError: @unittest.skipUnless(connection.vendor == "postgresql", "PostgreSQL specific tests") class PostgresConfigTests(TestCase): + def test_install_app_no_warning(self): + # Clear cache to force queries when (re)initializing the + # "django.contrib.postgres" app. + get_hstore_oids.cache_clear() + with CaptureQueriesContext(connection) as captured_queries: + with override_settings(INSTALLED_APPS=["django.contrib.postgres"]): + pass + self.assertGreaterEqual(len(captured_queries), 1) + def test_register_type_handlers_connection(self): from django.contrib.postgres.signals import register_type_handlers |
