Skip to content
Browse files

Add @slow wrapper to avoid running slow tests.

Use ./run_tests -f to only run the fast tests.
  • Loading branch information...
1 parent 91fff48 commit 844c5ed8c7656cc7bdeaff3b7dfd3aa950bc04c7 @nvie committed Feb 24, 2012
Showing with 22 additions and 4 deletions.
  1. +2 −2 rq/timeouts.py
  2. +5 −0 run_tests
  3. +12 −0 tests/__init__.py
  4. +3 −2 tests/test_worker.py
View
4 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):
View
5 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
View
12 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.
View
5 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'

0 comments on commit 844c5ed

Please sign in to comment.
Something went wrong with that request. Please try again.