Skip to content

Commit

Permalink
Improve --runslow implementation in conftest
Browse files Browse the repository at this point in the history
Pulled out from dask#6989. This minor refactor makes it easier to add other config options in the future. It also ensure that the `ws` marker is added even when `--runslow` is given.
  • Loading branch information
gjoseph92 committed Sep 2, 2022
1 parent 6da758b commit 80960e6
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# https://pytest.org/latest/example/simple.html#control-skipping-of-tests-according-to-command-line-option
from __future__ import annotations

import pytest
Expand Down Expand Up @@ -27,13 +26,14 @@ def pytest_addoption(parser):


def pytest_collection_modifyitems(config, items):
if config.getoption("--runslow"):
# --runslow given in cli: do not skip slow tests
return
skip_slow = pytest.mark.skip(reason="need --runslow option to run")
# https://pytest.org/latest/example/simple.html#control-skipping-of-tests-according-to-command-line-option
if skip_slow := not config.getoption("--runslow"):
# --runslow not given in cli: skip slow tests
skip_slow_marker = pytest.mark.skip(reason="need --runslow option to run")

for item in items:
if "slow" in item.keywords:
item.add_marker(skip_slow)
if skip_slow and "slow" in item.keywords:
item.add_marker(skip_slow_marker)

if "ws" in item.fixturenames:
item.add_marker(pytest.mark.workerstate)
Expand Down

0 comments on commit 80960e6

Please sign in to comment.