Skip to content

Commit

Permalink
Run slow tests on travis
Browse files Browse the repository at this point in the history
  • Loading branch information
Chronial committed May 17, 2018
1 parent a30f636 commit f2b1bab
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ install:
- pip install -e .
- pip install pytest pytest-cov coveralls pytest-mock flake8 flake8-isort
script:
- py.test --cov redis_tasks --run-slow
- flake8 .
- RUN_SLOW_TESTS_TOO=1 py.test --cov rq --durations=5
after_success:
- coveralls
11 changes: 11 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@
os.environ[conf.ENVIRONMENT_VARIABLE] = 'tests.app.settings'


def pytest_addoption(parser):
parser.addoption("--run-slow", action="store_true", help="run slow tests")


@pytest.hookimpl(tryfirst=True)
def pytest_runtest_setup(item):
if not pytest.config.getoption("--run-slow"):
if item.keywords.get('slow'):
pytest.skip("Test is marked as slow")


def pytest_unconfigure(config):
do_clear_redis()

Expand Down
2 changes: 1 addition & 1 deletion tests/test_maintenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from redis_tasks.worker_process import Maintenance


@pytest.mark.skip
@pytest.mark.slow
def test_run_if_necessary(mocker, settings):
settings.MAINTENANCE_FREQ = 2
maintenance = Maintenance()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,6 @@ def in_thread():
assert Queue.await_multi([q1, q2], 1).name == q1.name


@pytest.mark.skip
@pytest.mark.slow
def test_queue_await_multi_empty():
assert Queue.await_multi([Queue()], 1) is None
6 changes: 3 additions & 3 deletions tests/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,21 +275,21 @@ def test_basic(self, caplog):
m.extend()
assert not caplog.records

@pytest.mark.skip
@pytest.mark.slow
def test_blocked(self, caplog):
with Mutex(timeout=3):
with pytest.raises(RuntimeError):
with Mutex(timeout=0.1):
pass
assert 'already running' in one(caplog.records).message

@pytest.mark.skip
@pytest.mark.slow
def test_unblocked(self, caplog):
with Mutex(timeout=0.01):
with Mutex(timeout=0.01):
assert 'already running' in one(caplog.records).message

@pytest.mark.skip
@pytest.mark.slow
def test_extend(self):
with Mutex(timeout=0.02) as m:
time.sleep(0.01)
Expand Down

0 comments on commit f2b1bab

Please sign in to comment.