diff options
Diffstat (limited to 'django/db/backends/postgresql')
| -rw-r--r-- | django/db/backends/postgresql/creation.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/django/db/backends/postgresql/creation.py b/django/db/backends/postgresql/creation.py index 70c3eda566..690bf9639b 100644 --- a/django/db/backends/postgresql/creation.py +++ b/django/db/backends/postgresql/creation.py @@ -1,6 +1,6 @@ import sys -from psycopg2 import errorcodes +from psycopg2 import errors from django.core.exceptions import ImproperlyConfigured from django.db.backends.base.creation import BaseDatabaseCreation @@ -46,7 +46,8 @@ class DatabaseCreation(BaseDatabaseCreation): return super()._execute_create_test_db(cursor, parameters, keepdb) except Exception as e: - if getattr(e.__cause__, "pgcode", "") != errorcodes.DUPLICATE_DATABASE: + cause = e.__cause__ + if cause and not isinstance(cause, errors.DuplicateDatabase): # All errors except "database already exists" cancel tests. self.log("Got an error creating the test database: %s" % e) sys.exit(2) |
