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 ...
remotes/origin/enhancement/email-actions
Anler Hp 2014-05-22 15:20:38 +02:00 committed by David Barragán Merino
parent 55f5c70e4e
commit ac49a76146
1 changed files with 9 additions and 2 deletions

View File

@ -1,5 +1,3 @@
from collections import namedtuple
import pytest import pytest
@ -10,3 +8,12 @@ class Object:
@pytest.fixture @pytest.fixture
def object(): def object():
return 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")