|
19 | 19 |
|
20 | 20 | import pytest |
21 | 21 | from roundup.hyperdb import DatabaseError |
| 22 | +from roundup.backends import get_backend, have_backend |
22 | 23 |
|
23 | 24 | from db_test_base import DBTest, ROTest, config, SchemaTest, ClassicInitTest |
24 | 25 | from db_test_base import ConcurrentDBTest, HTMLItemTest, FilterCacheTest |
25 | 26 | from db_test_base import ClassicInitBase, setupTracker |
26 | 27 |
|
27 | | -from roundup.backends import get_backend, have_backend |
28 | | -from roundup.backends.back_postgresql import psycopg |
29 | | - |
30 | 28 | if not have_backend('postgresql'): |
31 | 29 | # FIX: workaround for a bug in pytest.mark.skip(): |
32 | 30 | # https://github.com/pytest-dev/pytest/issues/568 |
33 | 31 | from .pytest_patcher import mark_class |
34 | 32 | skip_postgresql = mark_class(pytest.mark.skip( |
35 | 33 | reason='Skipping PostgreSQL tests: backend not available')) |
36 | 34 | else: |
37 | | - skip_postgresql = lambda func, *args, **kwargs: func |
38 | | - |
| 35 | + try: |
| 36 | + from roundup.backends.back_postgresql import psycopg, db_command |
| 37 | + db_command(config, 'select 1') |
| 38 | + skip_postgresql = lambda func, *args, **kwargs: func |
| 39 | + except( DatabaseError ) as msg: |
| 40 | + from .pytest_patcher import mark_class |
| 41 | + skip_postgresql = mark_class(pytest.mark.skip( |
| 42 | + reason='Skipping PostgreSQL tests: database not available')) |
39 | 43 |
|
| 44 | +@skip_postgresql |
40 | 45 | class postgresqlOpener: |
41 | 46 | if have_backend('postgresql'): |
42 | 47 | module = get_backend('postgresql') |
|
0 commit comments