Mercurial > p > roundup > code
diff test/test_postgresql.py @ 5215:917e45d9ba08
test_postgress isn't properly skipping tests when database is not
accessible. Trying to use the model from test_mysql to see
that properly skips the postgres tests.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Mon, 20 Mar 2017 21:22:28 -0400 |
| parents | 57452bc6d989 |
| children | 198b6e810c67 |
line wrap: on
line diff
--- a/test/test_postgresql.py Mon Mar 20 20:18:20 2017 -0400 +++ b/test/test_postgresql.py Mon Mar 20 21:22:28 2017 -0400 @@ -19,14 +19,12 @@ import pytest from roundup.hyperdb import DatabaseError +from roundup.backends import get_backend, have_backend from db_test_base import DBTest, ROTest, config, SchemaTest, ClassicInitTest from db_test_base import ConcurrentDBTest, HTMLItemTest, FilterCacheTest from db_test_base import ClassicInitBase, setupTracker -from roundup.backends import get_backend, have_backend -from roundup.backends.back_postgresql import psycopg - if not have_backend('postgresql'): # FIX: workaround for a bug in pytest.mark.skip(): # https://github.com/pytest-dev/pytest/issues/568 @@ -34,9 +32,16 @@ skip_postgresql = mark_class(pytest.mark.skip( reason='Skipping PostgreSQL tests: backend not available')) else: - skip_postgresql = lambda func, *args, **kwargs: func + try: + from roundup.backends.back_postgresql import psycopg, db_command + db_command(config, 'select 1') + skip_postgresql = lambda func, *args, **kwargs: func + except( DatabaseError ) as msg: + from .pytest_patcher import mark_class + skip_postgresql = mark_class(pytest.mark.skip( + reason='Skipping PostgreSQL tests: database not available')) - +@skip_postgresql class postgresqlOpener: if have_backend('postgresql'): module = get_backend('postgresql')
