Add @slow wrapper to avoid running slow tests.

Use ./run_tests -f to only run the fast tests.
main
Vincent Driessen 13 years ago
parent 91fff48389
commit 844c5ed8c7

@ -27,8 +27,8 @@ class death_pentalty_after(object):
# __exit__ may return True to supress further exception handling. We # __exit__ may return True to supress further exception handling. We
# don't want to suppress any exceptions here, since all errors should # don't want to suppress any exceptions here, since all errors should
# just pass through, JobTimeoutException being handled as just one of # just pass through, JobTimeoutException being handled normally to the
# them. # invoking context.
return False return False
def handle_death_penalty(self, signum, frame): def handle_death_penalty(self, signum, frame):

@ -11,6 +11,11 @@ else
safe_rg=cat safe_rg=cat
fi 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 if check_redis_running; then
/usr/bin/env python -m unittest discover -v -s tests $@ 2>&1 | egrep -v '^test_' | $safe_rg /usr/bin/env python -m unittest discover -v -s tests $@ 2>&1 | egrep -v '^test_' | $safe_rg
else else

@ -15,6 +15,18 @@ def find_empty_redis_database():
assert False, 'No empty Redis database found to run tests in.' 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): class RQTestCase(unittest.TestCase):
"""Base class to inherit test cases from for RQ. """Base class to inherit test cases from for RQ.

@ -1,5 +1,5 @@
import os import os
from tests import RQTestCase from tests import RQTestCase, slow
from tests.fixtures import say_hello, div_by_zero, do_nothing, create_file, \ from tests.fixtures import say_hello, div_by_zero, do_nothing, create_file, \
create_file_after_timeout create_file_after_timeout
from tests.helpers import strip_milliseconds from tests.helpers import strip_milliseconds
@ -134,7 +134,8 @@ class TestWorker(RQTestCase):
assert self.testconn.exists(job_without_rv.key) == False 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.""" """Worker kills jobs after timeout."""
sentinel_file = '/tmp/.rq_sentinel' sentinel_file = '/tmp/.rq_sentinel'

Loading…
Cancel
Save