diff --git a/rq/timeouts.py b/rq/timeouts.py index 83be1e6f9..72b827e3c 100644 --- a/rq/timeouts.py +++ b/rq/timeouts.py @@ -27,8 +27,8 @@ def __exit__(self, type, value, traceback): # __exit__ may return True to supress further exception handling. We # don't want to suppress any exceptions here, since all errors should - # just pass through, JobTimeoutException being handled as just one of - # them. + # just pass through, JobTimeoutException being handled normally to the + # invoking context. return False def handle_death_penalty(self, signum, frame): diff --git a/run_tests b/run_tests index 4ac4f7e87..670b438f1 100755 --- a/run_tests +++ b/run_tests @@ -11,6 +11,11 @@ else safe_rg=cat fi +export ONLY_RUN_FAST_TESTS=1 +if [ "$1" == '-f' ]; then # Poor man's argparse + unset ONLY_RUN_FAST_TESTS +fi + if check_redis_running; then /usr/bin/env python -m unittest discover -v -s tests $@ 2>&1 | egrep -v '^test_' | $safe_rg else diff --git a/tests/__init__.py b/tests/__init__.py index 76895a438..2d54f29d2 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -15,6 +15,18 @@ def find_empty_redis_database(): 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) + + return _inner + + class RQTestCase(unittest.TestCase): """Base class to inherit test cases from for RQ. diff --git a/tests/test_worker.py b/tests/test_worker.py index b1aa68cf1..92f177cae 100644 --- a/tests/test_worker.py +++ b/tests/test_worker.py @@ -1,5 +1,5 @@ import os -from tests import RQTestCase +from tests import RQTestCase, slow from tests.fixtures import say_hello, div_by_zero, do_nothing, create_file, \ create_file_after_timeout from tests.helpers import strip_milliseconds @@ -134,7 +134,8 @@ def test_cleaning_up_of_jobs(self): assert self.testconn.exists(job_without_rv.key) == False - def test_timeouts(self): # noqa + @slow # noqa + def test_timeouts(self): """Worker kills jobs after timeout.""" sentinel_file = '/tmp/.rq_sentinel'