import nose.case
from nose.plugins import Plugin
-
+from nose import SkipTest
from test.bootstrap import config
from test.bootstrap.config import (
if not issubclass(cls, fixtures.TestBase):
return False
else:
- if (hasattr(cls, '__whitelist__') and testing.db.name in cls.__whitelist__):
- return True
+ if hasattr(cls, 'setup_class'):
+ existing_setup = cls.setup_class.im_func
else:
- return not self.__should_skip_for(cls)
+ existing_setup = None
+ @classmethod
+ def setup_class(cls):
+ self._do_skips(cls)
+ if existing_setup:
+ existing_setup(cls)
+ cls.setup_class = setup_class
+
+ return True
- def __should_skip_for(self, cls):
+ def _do_skips(self, cls):
if hasattr(cls, '__requires__'):
def test_suite(): return 'ok'
test_suite.__name__ = cls.__name__
for requirement in cls.__requires__:
check = getattr(requires, requirement)
- if check(test_suite)() != 'ok':
- # The requirement will perform messaging.
- return True
+ check(test_suite)()
if cls.__unsupported_on__:
spec = testing.db_spec(*cls.__unsupported_on__)
if spec(testing.db):
- print "'%s' unsupported on DB implementation '%s'" % (
- cls.__class__.__name__, testing.db.name)
- return True
+ raise SkipTest(
+ "'%s' unsupported on DB implementation '%s'" % (
+ cls.__name__, testing.db.name)
+ )
if getattr(cls, '__only_on__', None):
spec = testing.db_spec(*util.to_list(cls.__only_on__))
if not spec(testing.db):
- print "'%s' unsupported on DB implementation '%s'" % (
- cls.__class__.__name__, testing.db.name)
- return True
+ raise SkipTest(
+ "'%s' unsupported on DB implementation '%s'" % (
+ cls.__name__, testing.db.name)
+ )
if getattr(cls, '__skip_if__', False):
for c in getattr(cls, '__skip_if__'):
if c():
- print "'%s' skipped by %s" % (
- cls.__class__.__name__, c.__name__)
- return True
-
- for rule in getattr(cls, '__excluded_on__', ()):
- if testing._is_excluded(*rule):
- print "'%s' unsupported on DB %s version %s" % (
- cls.__class__.__name__, testing.db.name,
- _server_version())
- return True
- return False
+ raise SkipTest("'%s' skipped by %s" % (
+ cls.__name__, c.__name__)
+ )
+
+ for db, op, spec in getattr(cls, '__excluded_on__', ()):
+ testing.exclude(db, op, spec, "'%s' unsupported on DB %s version %s" % (
+ cls.__name__, testing.db.name,
+ testing._server_version()))
def beforeTest(self, test):
testing.resetwarnings()
engines.testing_reaper._stop_test_ctx()
if not config.options.low_connections:
testing.global_cleanup_assertions()
-
- #def handleError(self, test, err):
- #pass
-
- #def finalize(self, result=None):
- #pass
if spec(config.db):
msg = "'%s' unsupported on DB implementation '%s+%s': %s" % (
fn.__name__, config.db.name, config.db.driver, reason)
- print msg
- if carp:
- print >> sys.stderr, msg
- return True
+ raise SkipTest(msg)
else:
return fn(*args, **kw)
return decorate
else:
msg = "'%s' unsupported on DB implementation '%s+%s': %s" % (
fn.__name__, config.db.name, config.db.driver, reason)
- print msg
- if carp:
- print >> sys.stderr, msg
- return True
+ raise SkipTest(msg)
return decorate
def exclude(db, op, spec, reason):
if _is_excluded(db, op, spec):
msg = "'%s' unsupported on DB %s version '%s': %s" % (
fn.__name__, config.db.name, _server_version(), reason)
- print msg
- if carp:
- print >> sys.stderr, msg
- return True
+ raise SkipTest(msg)
else:
return fn(*args, **kw)
return decorate
if predicate():
msg = "'%s' skipped on DB %s version '%s': %s" % (
fn.__name__, config.db.name, _server_version(), reason)
- print msg
- if carp:
- print >> sys.stderr, msg
- return True
+ raise SkipTest(msg)
else:
return fn(*args, **kw)
return decorate
Column('name', String(45), default=''),
)
-def generate_round_trip_test(use_unions=False, use_joins=False):
+def _generate_round_trip_test(use_unions=False, use_joins=False):
def test_roundtrip(self):
publication_mapper = mapper(Publication, publication_table)
setattr(MagazineTest, test_roundtrip.__name__, test_roundtrip)
for (use_union, use_join) in [(True, False), (False, True), (False, False)]:
- generate_round_trip_test(use_union, use_join)
+ _generate_round_trip_test(use_union, use_join)