mirror of https://github.com/django/django.git
Refs #33308 -- Ensured type handlers are registered for all PostgreSQL specific tests.
Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
This commit is contained in:
parent
3cafb783f3
commit
149b55fefa
|
@ -7,11 +7,15 @@ from django.test import SimpleTestCase, TestCase, modify_settings
|
||||||
|
|
||||||
|
|
||||||
@unittest.skipUnless(connection.vendor == "postgresql", "PostgreSQL specific tests")
|
@unittest.skipUnless(connection.vendor == "postgresql", "PostgreSQL specific tests")
|
||||||
|
# To register type handlers and locate the widget's template.
|
||||||
|
@modify_settings(INSTALLED_APPS={"append": "django.contrib.postgres"})
|
||||||
class PostgreSQLSimpleTestCase(SimpleTestCase):
|
class PostgreSQLSimpleTestCase(SimpleTestCase):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@unittest.skipUnless(connection.vendor == "postgresql", "PostgreSQL specific tests")
|
@unittest.skipUnless(connection.vendor == "postgresql", "PostgreSQL specific tests")
|
||||||
|
# To register type handlers and locate the widget's template.
|
||||||
|
@modify_settings(INSTALLED_APPS={"append": "django.contrib.postgres"})
|
||||||
class PostgreSQLTestCase(TestCase):
|
class PostgreSQLTestCase(TestCase):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
|
import unittest
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
|
||||||
|
from django.db import connection
|
||||||
from django.db.backends.signals import connection_created
|
from django.db.backends.signals import connection_created
|
||||||
from django.db.migrations.writer import MigrationWriter
|
from django.db.migrations.writer import MigrationWriter
|
||||||
|
from django.test import TestCase
|
||||||
from django.test.utils import modify_settings
|
from django.test.utils import modify_settings
|
||||||
|
|
||||||
from . import PostgreSQLTestCase
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from psycopg2.extras import DateRange, DateTimeRange, DateTimeTZRange, NumericRange
|
from psycopg2.extras import DateRange, DateTimeRange, DateTimeTZRange, NumericRange
|
||||||
|
|
||||||
|
@ -19,7 +20,8 @@ except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class PostgresConfigTests(PostgreSQLTestCase):
|
@unittest.skipUnless(connection.vendor == "postgresql", "PostgreSQL specific tests")
|
||||||
|
class PostgresConfigTests(TestCase):
|
||||||
def test_register_type_handlers_connection(self):
|
def test_register_type_handlers_connection(self):
|
||||||
from django.contrib.postgres.signals import register_type_handlers
|
from django.contrib.postgres.signals import register_type_handlers
|
||||||
|
|
||||||
|
|
|
@ -12,12 +12,7 @@ from django.core.management import call_command
|
||||||
from django.db import IntegrityError, connection, models
|
from django.db import IntegrityError, connection, models
|
||||||
from django.db.models.expressions import Exists, OuterRef, RawSQL, Value
|
from django.db.models.expressions import Exists, OuterRef, RawSQL, Value
|
||||||
from django.db.models.functions import Cast, JSONObject, Upper
|
from django.db.models.functions import Cast, JSONObject, Upper
|
||||||
from django.test import (
|
from django.test import TransactionTestCase, override_settings, skipUnlessDBFeature
|
||||||
TransactionTestCase,
|
|
||||||
modify_settings,
|
|
||||||
override_settings,
|
|
||||||
skipUnlessDBFeature,
|
|
||||||
)
|
|
||||||
from django.test.utils import isolate_apps
|
from django.test.utils import isolate_apps
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
||||||
|
@ -1259,8 +1254,6 @@ class TestSplitFormField(PostgreSQLSimpleTestCase):
|
||||||
with self.assertRaisesMessage(exceptions.ValidationError, msg):
|
with self.assertRaisesMessage(exceptions.ValidationError, msg):
|
||||||
SplitArrayField(forms.IntegerField(max_value=100), size=2).clean([0, 101])
|
SplitArrayField(forms.IntegerField(max_value=100), size=2).clean([0, 101])
|
||||||
|
|
||||||
# To locate the widget's template.
|
|
||||||
@modify_settings(INSTALLED_APPS={"append": "django.contrib.postgres"})
|
|
||||||
def test_rendering(self):
|
def test_rendering(self):
|
||||||
class SplitForm(forms.Form):
|
class SplitForm(forms.Form):
|
||||||
array = SplitArrayField(forms.CharField(), size=3)
|
array = SplitArrayField(forms.CharField(), size=3)
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
from datetime import date
|
from datetime import date
|
||||||
|
|
||||||
from django.test import modify_settings
|
|
||||||
|
|
||||||
from . import PostgreSQLTestCase
|
from . import PostgreSQLTestCase
|
||||||
from .models import (
|
from .models import (
|
||||||
HStoreModel,
|
HStoreModel,
|
||||||
|
@ -18,7 +16,6 @@ except ImportError:
|
||||||
pass # psycopg2 isn't installed.
|
pass # psycopg2 isn't installed.
|
||||||
|
|
||||||
|
|
||||||
@modify_settings(INSTALLED_APPS={"append": "django.contrib.postgres"})
|
|
||||||
class BulkSaveTests(PostgreSQLTestCase):
|
class BulkSaveTests(PostgreSQLTestCase):
|
||||||
def test_bulk_update(self):
|
def test_bulk_update(self):
|
||||||
test_data = [
|
test_data = [
|
||||||
|
|
|
@ -5,14 +5,12 @@ strings and thus eliminates the need for operations such as iexact and other
|
||||||
modifiers to enforce use of an index.
|
modifiers to enforce use of an index.
|
||||||
"""
|
"""
|
||||||
from django.db import IntegrityError
|
from django.db import IntegrityError
|
||||||
from django.test.utils import modify_settings
|
|
||||||
from django.utils.deprecation import RemovedInDjango51Warning
|
from django.utils.deprecation import RemovedInDjango51Warning
|
||||||
|
|
||||||
from . import PostgreSQLTestCase
|
from . import PostgreSQLTestCase
|
||||||
from .models import CITestModel
|
from .models import CITestModel
|
||||||
|
|
||||||
|
|
||||||
@modify_settings(INSTALLED_APPS={"append": "django.contrib.postgres"})
|
|
||||||
class CITextTestCase(PostgreSQLTestCase):
|
class CITextTestCase(PostgreSQLTestCase):
|
||||||
case_sensitive_lookups = ("contains", "startswith", "endswith", "regex")
|
case_sensitive_lookups = ("contains", "startswith", "endswith", "regex")
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ from django.db.models import (
|
||||||
)
|
)
|
||||||
from django.db.models.fields.json import KeyTextTransform
|
from django.db.models.fields.json import KeyTextTransform
|
||||||
from django.db.models.functions import Cast, Left, Lower
|
from django.db.models.functions import Cast, Left, Lower
|
||||||
from django.test import ignore_warnings, modify_settings, skipUnlessDBFeature
|
from django.test import ignore_warnings, skipUnlessDBFeature
|
||||||
from django.test.utils import isolate_apps
|
from django.test.utils import isolate_apps
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.utils.deprecation import RemovedInDjango50Warning
|
from django.utils.deprecation import RemovedInDjango50Warning
|
||||||
|
@ -37,7 +37,6 @@ except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@modify_settings(INSTALLED_APPS={"append": "django.contrib.postgres"})
|
|
||||||
class SchemaTests(PostgreSQLTestCase):
|
class SchemaTests(PostgreSQLTestCase):
|
||||||
get_opclass_query = """
|
get_opclass_query = """
|
||||||
SELECT opcname, c.relname FROM pg_opclass AS oc
|
SELECT opcname, c.relname FROM pg_opclass AS oc
|
||||||
|
@ -255,7 +254,6 @@ class SchemaTests(PostgreSQLTestCase):
|
||||||
Scene.objects.create(scene="ScEnE 10", setting="Sir Bedemir's Castle")
|
Scene.objects.create(scene="ScEnE 10", setting="Sir Bedemir's Castle")
|
||||||
|
|
||||||
|
|
||||||
@modify_settings(INSTALLED_APPS={"append": "django.contrib.postgres"})
|
|
||||||
class ExclusionConstraintTests(PostgreSQLTestCase):
|
class ExclusionConstraintTests(PostgreSQLTestCase):
|
||||||
def get_constraints(self, table):
|
def get_constraints(self, table):
|
||||||
"""Get the constraints on the table using a new cursor."""
|
"""Get the constraints on the table using a new cursor."""
|
||||||
|
@ -1198,7 +1196,6 @@ class ExclusionConstraintTests(PostgreSQLTestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@modify_settings(INSTALLED_APPS={"append": "django.contrib.postgres"})
|
|
||||||
class ExclusionConstraintOpclassesDepracationTests(PostgreSQLTestCase):
|
class ExclusionConstraintOpclassesDepracationTests(PostgreSQLTestCase):
|
||||||
def get_constraints(self, table):
|
def get_constraints(self, table):
|
||||||
"""Get the constraints on the table using a new cursor."""
|
"""Get the constraints on the table using a new cursor."""
|
||||||
|
|
|
@ -15,7 +15,7 @@ from django.db import NotSupportedError, connection
|
||||||
from django.db.models import CharField, F, Index, Q
|
from django.db.models import CharField, F, Index, Q
|
||||||
from django.db.models.functions import Cast, Collate, Length, Lower
|
from django.db.models.functions import Cast, Collate, Length, Lower
|
||||||
from django.test import skipUnlessDBFeature
|
from django.test import skipUnlessDBFeature
|
||||||
from django.test.utils import modify_settings, register_lookup
|
from django.test.utils import register_lookup
|
||||||
|
|
||||||
from . import PostgreSQLSimpleTestCase, PostgreSQLTestCase
|
from . import PostgreSQLSimpleTestCase, PostgreSQLTestCase
|
||||||
from .fields import SearchVector, SearchVectorField
|
from .fields import SearchVector, SearchVectorField
|
||||||
|
@ -235,7 +235,6 @@ class SpGistIndexTests(IndexTestMixin, PostgreSQLSimpleTestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@modify_settings(INSTALLED_APPS={"append": "django.contrib.postgres"})
|
|
||||||
class SchemaTests(PostgreSQLTestCase):
|
class SchemaTests(PostgreSQLTestCase):
|
||||||
get_opclass_query = """
|
get_opclass_query = """
|
||||||
SELECT opcname, c.relname FROM pg_opclass AS oc
|
SELECT opcname, c.relname FROM pg_opclass AS oc
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
|
|
||||||
from django.core.management import call_command
|
from django.core.management import call_command
|
||||||
from django.test.utils import modify_settings
|
|
||||||
|
|
||||||
from . import PostgreSQLTestCase
|
from . import PostgreSQLTestCase
|
||||||
|
|
||||||
|
|
||||||
@modify_settings(INSTALLED_APPS={"append": "django.contrib.postgres"})
|
|
||||||
class InspectDBTests(PostgreSQLTestCase):
|
class InspectDBTests(PostgreSQLTestCase):
|
||||||
def assertFieldsInModel(self, model, field_outputs):
|
def assertFieldsInModel(self, model, field_outputs):
|
||||||
out = StringIO()
|
out = StringIO()
|
||||||
|
|
|
@ -7,7 +7,6 @@ transcript.
|
||||||
"""
|
"""
|
||||||
from django.db import connection
|
from django.db import connection
|
||||||
from django.db.models import F, Value
|
from django.db.models import F, Value
|
||||||
from django.test import modify_settings
|
|
||||||
|
|
||||||
from . import PostgreSQLSimpleTestCase, PostgreSQLTestCase
|
from . import PostgreSQLSimpleTestCase, PostgreSQLTestCase
|
||||||
from .models import Character, Line, LineSavedSearch, Scene
|
from .models import Character, Line, LineSavedSearch, Scene
|
||||||
|
@ -103,7 +102,6 @@ class GrailTestData:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@modify_settings(INSTALLED_APPS={"append": "django.contrib.postgres"})
|
|
||||||
class SimpleSearchTest(GrailTestData, PostgreSQLTestCase):
|
class SimpleSearchTest(GrailTestData, PostgreSQLTestCase):
|
||||||
def test_simple(self):
|
def test_simple(self):
|
||||||
searched = Line.objects.filter(dialogue__search="elbows")
|
searched = Line.objects.filter(dialogue__search="elbows")
|
||||||
|
@ -140,7 +138,6 @@ class SimpleSearchTest(GrailTestData, PostgreSQLTestCase):
|
||||||
self.assertSequenceEqual(searched, [match])
|
self.assertSequenceEqual(searched, [match])
|
||||||
|
|
||||||
|
|
||||||
@modify_settings(INSTALLED_APPS={"append": "django.contrib.postgres"})
|
|
||||||
class SearchVectorFieldTest(GrailTestData, PostgreSQLTestCase):
|
class SearchVectorFieldTest(GrailTestData, PostgreSQLTestCase):
|
||||||
def test_existing_vector(self):
|
def test_existing_vector(self):
|
||||||
Line.objects.update(dialogue_search_vector=SearchVector("dialogue"))
|
Line.objects.update(dialogue_search_vector=SearchVector("dialogue"))
|
||||||
|
@ -339,7 +336,6 @@ class MultipleFieldsTest(GrailTestData, PostgreSQLTestCase):
|
||||||
self.assertSequenceEqual(searched, [self.french])
|
self.assertSequenceEqual(searched, [self.french])
|
||||||
|
|
||||||
|
|
||||||
@modify_settings(INSTALLED_APPS={"append": "django.contrib.postgres"})
|
|
||||||
class TestCombinations(GrailTestData, PostgreSQLTestCase):
|
class TestCombinations(GrailTestData, PostgreSQLTestCase):
|
||||||
def test_vector_add(self):
|
def test_vector_add(self):
|
||||||
searched = Line.objects.annotate(
|
searched = Line.objects.annotate(
|
||||||
|
@ -462,7 +458,6 @@ class TestCombinations(GrailTestData, PostgreSQLTestCase):
|
||||||
Line.objects.filter(dialogue__search=None & SearchQuery("kneecaps"))
|
Line.objects.filter(dialogue__search=None & SearchQuery("kneecaps"))
|
||||||
|
|
||||||
|
|
||||||
@modify_settings(INSTALLED_APPS={"append": "django.contrib.postgres"})
|
|
||||||
class TestRankingAndWeights(GrailTestData, PostgreSQLTestCase):
|
class TestRankingAndWeights(GrailTestData, PostgreSQLTestCase):
|
||||||
def test_ranking(self):
|
def test_ranking(self):
|
||||||
searched = (
|
searched = (
|
||||||
|
@ -661,7 +656,6 @@ class SearchQueryTests(PostgreSQLSimpleTestCase):
|
||||||
self.assertEqual(str(query), expected_str)
|
self.assertEqual(str(query), expected_str)
|
||||||
|
|
||||||
|
|
||||||
@modify_settings(INSTALLED_APPS={"append": "django.contrib.postgres"})
|
|
||||||
class SearchHeadlineTests(GrailTestData, PostgreSQLTestCase):
|
class SearchHeadlineTests(GrailTestData, PostgreSQLTestCase):
|
||||||
def test_headline(self):
|
def test_headline(self):
|
||||||
searched = Line.objects.annotate(
|
searched = Line.objects.annotate(
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
from django.test import modify_settings
|
|
||||||
|
|
||||||
from . import PostgreSQLTestCase
|
from . import PostgreSQLTestCase
|
||||||
from .models import CharFieldModel, TextFieldModel
|
from .models import CharFieldModel, TextFieldModel
|
||||||
|
|
||||||
|
@ -16,7 +14,6 @@ except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@modify_settings(INSTALLED_APPS={"append": "django.contrib.postgres"})
|
|
||||||
class TrigramTest(PostgreSQLTestCase):
|
class TrigramTest(PostgreSQLTestCase):
|
||||||
Model = CharFieldModel
|
Model = CharFieldModel
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
from django.db import connection
|
from django.db import connection
|
||||||
from django.test import modify_settings
|
|
||||||
|
|
||||||
from . import PostgreSQLTestCase
|
from . import PostgreSQLTestCase
|
||||||
from .models import CharFieldModel, TextFieldModel
|
from .models import CharFieldModel, TextFieldModel
|
||||||
|
|
||||||
|
|
||||||
@modify_settings(INSTALLED_APPS={"append": "django.contrib.postgres"})
|
|
||||||
class UnaccentTest(PostgreSQLTestCase):
|
class UnaccentTest(PostgreSQLTestCase):
|
||||||
|
|
||||||
Model = CharFieldModel
|
Model = CharFieldModel
|
||||||
|
|
Loading…
Reference in New Issue