Skip to content

Commit b1c8e53

Browse files
committed
test: skip test requiring postgresql backend if not present
1 parent 7612c47 commit b1c8e53

File tree

1 file changed

+34
-6
lines changed

1 file changed

+34
-6
lines changed

test/test_config.py

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,38 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717

18-
import unittest
19-
import logging
18+
import errno
2019
import fileinput
21-
22-
import os, shutil, errno, sys
23-
20+
import logging
21+
import os
2422
import pytest
23+
import shutil
24+
import sys
25+
import unittest
26+
2527
from roundup import configuration
28+
from roundup.backends import get_backend, have_backend
29+
from roundup.hyperdb import DatabaseError
30+
31+
from .db_test_base import config
32+
33+
if not have_backend('postgresql'):
34+
# FIX: workaround for a bug in pytest.mark.skip():
35+
# https://github.com/pytest-dev/pytest/issues/568
36+
from .pytest_patcher import mark_class
37+
skip_postgresql = mark_class(pytest.mark.skip(
38+
reason='Skipping PostgreSQL tests: backend not available'))
39+
else:
40+
try:
41+
from roundup.backends.back_postgresql import psycopg2, db_command,\
42+
get_database_schema_names
43+
db_command(config, 'select 1')
44+
skip_postgresql = lambda func, *args, **kwargs: func
45+
except( DatabaseError ) as msg:
46+
from .pytest_patcher import mark_class
47+
skip_postgresql = mark_class(pytest.mark.skip(
48+
reason='Skipping PostgreSQL tests: database not available'))
49+
2650

2751
try:
2852
import xapian
@@ -802,7 +826,7 @@ def testInvalidIndexerLanguage_w_native_fts(self):
802826
self.assertIn("basque", cm.exception.args[2])
803827

804828
@skip_redis
805-
def testLoadSessionDbRedis(self):
829+
def testLoadSessionDbRedisCompatible(self):
806830
""" run load to validate config """
807831

808832
config = configuration.CoreConfig()
@@ -819,6 +843,10 @@ def testLoadSessionDbRedis(self):
819843

820844
config.validator(config.options)
821845

846+
@skip_redis
847+
@skip_postgresql
848+
def testLoadSessionDbRedisIncompatible(self):
849+
""" run load to validate config """
822850
# incompatible pair
823851
config.RDBMS_BACKEND = "postgresql"
824852
config.SESSIONDB_BACKEND = "redis"

0 commit comments

Comments
 (0)