From ac49a76146ad002db7b726495556389dcca3f0f5 Mon Sep 17 00:00:00 2001 From: Anler Hp Date: Thu, 22 May 2014 15:20:38 +0200 Subject: [PATCH] Automatically skip slow tests You can mark a test as slow using: @pytest.mark.slow def test_something(): ... Use the option "--runslow" to tell the test runner to also include slow tests: py.test --runslow ... --- tests/conftest.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 945339f3..c32b0872 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,5 +1,3 @@ -from collections import namedtuple - import pytest @@ -10,3 +8,12 @@ class Object: @pytest.fixture def object(): return Object() + + +def pytest_addoption(parser): + parser.addoption("--runslow", action="store_true", help="run slow tests") + + +def pytest_runtest_setup(item): + if "slow" in item.keywords and not item.config.getoption("--runslow"): + pytest.skip("need --runslow option to run")