Merge "tests: Fix compatibility with PostgreSQL 14+"

This commit is contained in:
Zuul 2022-10-13 13:53:03 +00:00 committed by Gerrit Code Review
commit 8c7ecfd93e
1 changed files with 13 additions and 3 deletions

View File

@ -462,10 +462,20 @@ class TestNonExistentDatabasePostgreSQL(
self.url
)
self.assertEqual('non_existent_database', matched.database)
self.assertInnerException(
matched,
# NOTE(stephenfin): As above, we cannot use assertInnerException since
# the error messages vary depending on the version of PostgreSQL
self.assertIsInstance(
matched.inner_exception,
sqlalchemy.exc.OperationalError,
'fatal: database "non_existent_database" does not exist\n',
)
# On Postgres 13:
# fatal: database "non_existent_database" does not exist
# On Postgres 14 or later:
# connection to server at "localhost" (::1), port 5432 failed: fatal:
# database "non_existent_database" does not exist
self.assertIn(
'fatal: database "non_existent_database" does not exist',
str(matched.inner_exception).lower(),
)