Mercurial > p > roundup > code
diff test/test_postgresql.py @ 7841:673bb9cb41b4
test: fix ImportError if psycopg2 not installed
test_postgresql was reaching into roundup.backends.back_postgresql
before checking to see if psycopg2 was available. Move the (partly
duplicated) import inside the guard so it imports only if psycopg2 is
available.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Tue, 26 Mar 2024 22:35:24 -0400 |
| parents | 8147f6deac9f |
| children |
line wrap: on
line diff
--- a/test/test_postgresql.py Tue Mar 26 15:36:31 2024 -0400 +++ b/test/test_postgresql.py Tue Mar 26 22:35:24 2024 -0400 @@ -21,7 +21,6 @@ from roundup.hyperdb import DatabaseError from roundup.backends import get_backend, have_backend -from roundup.backends.back_postgresql import db_command, get_database_schema_names from .db_test_base import DBTest, ROTest, config, SchemaTest, ClassicInitTest from .db_test_base import ConcurrentDBTest, HTMLItemTest, FilterCacheTest @@ -36,7 +35,8 @@ reason='Skipping PostgreSQL tests: backend not available')) else: try: - from roundup.backends.back_postgresql import psycopg2, db_command + from roundup.backends.back_postgresql import psycopg2, db_command,\ + get_database_schema_names db_command(config, 'select 1') skip_postgresql = lambda func, *args, **kwargs: func except( DatabaseError ) as msg:
