| 1 |
import unittest |
| 2 |
|
| 3 |
from forms_tests.widget_tests.base import WidgetTest |
| 4 |
|
| 5 |
from django.db import connection |
| 6 |
from django.test import SimpleTestCase, TestCase, modify_settings |
| 7 |
from django.utils.functional import cached_property |
| 8 |
|
| 9 |
|
| 10 |
@unittest.skipUnless(connection.vendor == "postgresql", "PostgreSQL specific tests") |
| 11 |
# To register type handlers and locate the widget's template. |
| 12 |
@modify_settings(INSTALLED_APPS={"append": "django.contrib.postgres"}) |
| 13 |
class PostgreSQLSimpleTestCase(SimpleTestCase): |
| 14 |
pass |
| 15 |
|
| 16 |
|
| 17 |
@unittest.skipUnless(connection.vendor == "postgresql", "PostgreSQL specific tests") |
| 18 |
# To register type handlers and locate the widget's template. |
| 19 |
@modify_settings(INSTALLED_APPS={"append": "django.contrib.postgres"}) |
| 20 |
class PostgreSQLTestCase(TestCase): |
| 21 |
@cached_property |
| 22 |
def default_text_search_config(self): |
| 23 |
with connection.cursor() as cursor: |
| 24 |
cursor.execute("SHOW default_text_search_config") |
| 25 |
row = cursor.fetchone() |
| 26 |
return row[0] if row else None |
| 27 |
|
| 28 |
def check_default_text_search_config(self): |
| 29 |
if self.default_text_search_config != "pg_catalog.english": |
| 30 |
self.skipTest("The default text search config is not 'english'.") |
| 31 |
|
| 32 |
|
| 33 |
@unittest.skipUnless(connection.vendor == "postgresql", "PostgreSQL specific tests") |
| 34 |
# To locate the widget's template. |
| 35 |
@modify_settings(INSTALLED_APPS={"append": "django.contrib.postgres"}) |
| 36 |
class PostgreSQLWidgetTestCase(WidgetTest, PostgreSQLSimpleTestCase): |
| 37 |
pass |