summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2020-10-06 12:51:35 +0200
committerGitHub <noreply@github.com>2020-10-06 12:51:35 +0200
commit999cddd58d30469f3ee85278985313fdf528323d (patch)
tree81230701f3d93bfb7be29b284eebe8b5123d9f89 /tests
parent143d8e1ab3b7097c7d2bdf77096b96739b6239c6 (diff)
Fixed #32073 -- Skipped collation tests on PostgreSQL < 10.
PostgreSQL < 10 doesn't support ICU collations. Thanks Hannes Ljungberg for the report.
Diffstat (limited to 'tests')
-rw-r--r--tests/inspectdb/tests.py2
-rw-r--r--tests/schema/tests.py23
2 files changed, 20 insertions, 5 deletions
diff --git a/tests/inspectdb/tests.py b/tests/inspectdb/tests.py
index 6815629e95..b2da1c0a26 100644
--- a/tests/inspectdb/tests.py
+++ b/tests/inspectdb/tests.py
@@ -105,6 +105,7 @@ class InspectDBTestCase(TestCase):
self.assertIn('null_json_field = models.JSONField(blank=True, null=True)', output)
@skipUnlessDBFeature('supports_collation_on_charfield')
+ @skipUnless(test_collation, 'Language collations are not supported.')
def test_char_field_db_collation(self):
out = StringIO()
call_command('inspectdb', 'inspectdb_charfielddbcollation', stdout=out)
@@ -123,6 +124,7 @@ class InspectDBTestCase(TestCase):
)
@skipUnlessDBFeature('supports_collation_on_textfield')
+ @skipUnless(test_collation, 'Language collations are not supported.')
def test_text_field_db_collation(self):
out = StringIO()
call_command('inspectdb', 'inspectdb_textfielddbcollation', stdout=out)
diff --git a/tests/schema/tests.py b/tests/schema/tests.py
index 396d7c7c4f..49fda069d3 100644
--- a/tests/schema/tests.py
+++ b/tests/schema/tests.py
@@ -3236,7 +3236,9 @@ class SchemaTests(TransactionTestCase):
@isolate_apps('schema')
@skipUnlessDBFeature('supports_collation_on_charfield')
def test_db_collation_charfield(self):
- collation = connection.features.test_collations['non_default']
+ collation = connection.features.test_collations.get('non_default')
+ if not collation:
+ self.skipTest('Language collations are not supported.')
class Foo(Model):
field = CharField(max_length=255, db_collation=collation)
@@ -3256,7 +3258,9 @@ class SchemaTests(TransactionTestCase):
@isolate_apps('schema')
@skipUnlessDBFeature('supports_collation_on_textfield')
def test_db_collation_textfield(self):
- collation = connection.features.test_collations['non_default']
+ collation = connection.features.test_collations.get('non_default')
+ if not collation:
+ self.skipTest('Language collations are not supported.')
class Foo(Model):
field = TextField(db_collation=collation)
@@ -3275,10 +3279,13 @@ class SchemaTests(TransactionTestCase):
@skipUnlessDBFeature('supports_collation_on_charfield')
def test_add_field_db_collation(self):
+ collation = connection.features.test_collations.get('non_default')
+ if not collation:
+ self.skipTest('Language collations are not supported.')
+
with connection.schema_editor() as editor:
editor.create_model(Author)
- collation = connection.features.test_collations['non_default']
new_field = CharField(max_length=255, db_collation=collation)
new_field.set_attributes_from_name('alias')
with connection.schema_editor() as editor:
@@ -3292,10 +3299,13 @@ class SchemaTests(TransactionTestCase):
@skipUnlessDBFeature('supports_collation_on_charfield')
def test_alter_field_db_collation(self):
+ collation = connection.features.test_collations.get('non_default')
+ if not collation:
+ self.skipTest('Language collations are not supported.')
+
with connection.schema_editor() as editor:
editor.create_model(Author)
- collation = connection.features.test_collations['non_default']
old_field = Author._meta.get_field('name')
new_field = CharField(max_length=255, db_collation=collation)
new_field.set_attributes_from_name('name')
@@ -3312,10 +3322,13 @@ class SchemaTests(TransactionTestCase):
@skipUnlessDBFeature('supports_collation_on_charfield')
def test_alter_field_type_and_db_collation(self):
+ collation = connection.features.test_collations.get('non_default')
+ if not collation:
+ self.skipTest('Language collations are not supported.')
+
with connection.schema_editor() as editor:
editor.create_model(Note)
- collation = connection.features.test_collations['non_default']
old_field = Note._meta.get_field('info')
new_field = CharField(max_length=255, db_collation=collation)
new_field.set_attributes_from_name('info')