import logging from rq.compat import is_python_version if is_python_version((2, 7), (3, 2)): import unittest else: import unittest2 as unittest # noqa from redis import StrictRedis from rq import push_connection, pop_connection def find_empty_redis_database(): """Tries to connect to a random Redis database (starting from 4), and will use/connect it when no keys are in there. """ for dbnum in range(4, 17): testconn = StrictRedis(db=dbnum) empty = len(testconn.keys('*')) == 0 if empty: return testconn assert False, 'No empty Redis database found to run tests in.' def slow(f): import os from functools import wraps @wraps(f) def _inner(*args, **kwargs): if os.environ.get('ONLY_RUN_FAST_TESTS'): f(*args, **kwargs)
# -*- coding: utf-8 -*- from __future__ import (absolute_import, division, print_function, unicode_literals) from click.testing import CliRunner from rq import get_failed_queue, Queue from rq.compat import is_python_version from rq.job import Job from rq.cli import main from rq.cli.helpers import read_config_file from tests import RQTestCase from tests.fixtures import div_by_zero if is_python_version((2, 7), (3, 2)): from unittest import TestCase else: from unittest2 import TestCase # noqa class TestCommandLine(TestCase): def test_config_file(self): settings = read_config_file("tests.dummy_settings") self.assertIn("REDIS_HOST", settings) self.assertEqual(settings['REDIS_HOST'], "testhost.example.com") class TestRQCli(RQTestCase): def assert_normal_execution(self, result): if result.exit_code == 0: return True