1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Refs #32508 -- Raised ImproperlyConfigured/TypeError instead of using "assert".

This commit is contained in:
Mateo Radman
2021-07-02 19:33:48 +02:00
committed by Mariusz Felisiak
parent 1ff0ea6e9b
commit 2231429991
4 changed files with 28 additions and 4 deletions

View File

@@ -3,6 +3,7 @@ from contextlib import contextmanager
from io import StringIO
from unittest import mock
from django.core.exceptions import ImproperlyConfigured
from django.db import DatabaseError, connection
from django.db.backends.base.creation import BaseDatabaseCreation
from django.test import SimpleTestCase
@@ -61,6 +62,15 @@ class DatabaseCreationTests(SimpleTestCase):
settings = {'CHARSET': 'UTF8', 'TEMPLATE': 'template0'}
self.check_sql_table_creation_suffix(settings, '''WITH ENCODING 'UTF8' TEMPLATE "template0"''')
def test_sql_table_creation_raises_with_collation(self):
settings = {'COLLATION': 'test'}
msg = (
'PostgreSQL does not support collation setting at database '
'creation time.'
)
with self.assertRaisesMessage(ImproperlyConfigured, msg):
self.check_sql_table_creation_suffix(settings, None)
def _execute_raise_database_already_exists(self, cursor, parameters, keepdb=False):
error = DatabaseError('database %s already exists' % parameters['dbname'])
error.pgcode = errorcodes.DUPLICATE_DATABASE