Checking database name directly.

This commit is contained in:
Roland 2022-01-07 14:03:59 -07:00
parent b9606c1b31
commit ad53cec428
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93

View file

@ -72,7 +72,7 @@ def get_db_context() -> Tuple[create_engine, Session]:
Get a DB engine and session.
"""
local_engine, session = _get_db_session()
if PYTEST and 'wrolpi_testing' not in str(local_engine.url):
if PYTEST and not local_engine.url.database.startswith('wrolpi_testing_'):
raise ValueError(f'Running tests, but a test database is not being used!! {local_engine.url=}')
return local_engine, session