def skip_on_travis(fn): """ A decorator that just skips some tests on travis-ci.org """ @functools.wraps(fn) def newfunc(self, *args, **kw): if os.environ.get('TRAVIS', None): raise SkipTest("gpg permissions are weird on travis-ci.org") return fn(self, *args, **kw) return make_decorator(fn)(newfunc)
def decorator(fn): @override_settings( CELERY_ALWAYS_EAGER=eager, CELERY_EAGER_PROPAGATES_EXCEPTIONS=propagate_exceptions) def wrapper(*args, **kwargs): return fn(*args, **kwargs) return make_decorator(fn)(wrapper)
def networked(func): """A decorator that skips tests if $NETWORKED is false or undefined. This decorator allows us to have tests that a developer might want to run but shouldn't be run by random people building the package. It also makes non-networked build systems happy. """ @functools.wraps(func) def newfunc(self, *args, **kw): if not _asbool(os.environ.get('NETWORKED', 'False')): raise SkipTest('Only run if you have network access.') return func(self, *args, **kw) return make_decorator(func)(newfunc)
def dev_only(func): """A decorator that skips tests if they are not run by a developer. This decorator allows us to have tests that a developer might want to run but shouldn't be run by random people building the package. It also makes non-networked build systems happy. """ @functools.wraps(func) def newfunc(self, *args, **kw): if not os.environ.get('DEVELOPER_TESTS', None): raise SkipTest('Only run if you are a python-fedora developer') return func(self, *args, **kw) return make_decorator(func)(newfunc)
def skip_if_fedmsg_meta_FI_is_present(f): """ A test decorator that will skip if fedmsg_meta_fedora_infrastructure is installed. The presence of that module will screw up some tests. """ def _wrapper(self, *args, **kw): try: import fedmsg_meta_fedora_infrastructure raise SkipTest("fedmsg_meta_FI is present") except ImportError: pass return f(self, *args, **kw) return make_decorator(f)(_wrapper)