From 2f120ac51722a257219a7577759702605cefddf4 Mon Sep 17 00:00:00 2001 From: Simon Charette Date: Mon, 12 Nov 2018 11:15:48 -0500 Subject: Fixed #29945 -- Moved contrib.postgres uninstallation logic to the app config. --- tests/postgres_tests/__init__.py | 9 +-------- tests/postgres_tests/test_apps.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 8 deletions(-) create mode 100644 tests/postgres_tests/test_apps.py (limited to 'tests/postgres_tests') diff --git a/tests/postgres_tests/__init__.py b/tests/postgres_tests/__init__.py index 24d78c9bfe..d2e5d3bea4 100644 --- a/tests/postgres_tests/__init__.py +++ b/tests/postgres_tests/__init__.py @@ -3,19 +3,12 @@ import unittest from forms_tests.widget_tests.base import WidgetTest from django.db import connection -from django.db.backends.signals import connection_created from django.test import TestCase, modify_settings @unittest.skipUnless(connection.vendor == 'postgresql', "PostgreSQL specific tests") class PostgreSQLTestCase(TestCase): - @classmethod - def tearDownClass(cls): - # No need to keep that signal overhead for non PostgreSQL-related tests. - from django.contrib.postgres.signals import register_type_handlers - - connection_created.disconnect(register_type_handlers) - super().tearDownClass() + pass @unittest.skipUnless(connection.vendor == 'postgresql', "PostgreSQL specific tests") diff --git a/tests/postgres_tests/test_apps.py b/tests/postgres_tests/test_apps.py new file mode 100644 index 0000000000..a5740f9d15 --- /dev/null +++ b/tests/postgres_tests/test_apps.py @@ -0,0 +1,13 @@ +from django.db.backends.signals import connection_created +from django.test.utils import modify_settings + +from . import PostgreSQLTestCase + + +class PostgresConfigTests(PostgreSQLTestCase): + def test_register_type_handlers_connection(self): + from django.contrib.postgres.signals import register_type_handlers + self.assertNotIn(register_type_handlers, connection_created._live_receivers(None)) + with modify_settings(INSTALLED_APPS={'append': 'django.contrib.postgres'}): + self.assertIn(register_type_handlers, connection_created._live_receivers(None)) + self.assertNotIn(register_type_handlers, connection_created._live_receivers(None)) -- cgit v1.3