Skip to content

Commit

Permalink
Mark slow test to skip in default pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
Yao authored and l2yao committed Feb 3, 2020
1 parent cd6add3 commit 9570493
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
15 changes: 15 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,21 @@

def pytest_addoption(parser):
parser.addoption("--boto-model-file", action="store", default=None)
parser.addoption("--runslow", action="store_true", default=False, help="run slow tests")


def pytest_configure(config):
config.addinivalue_line("markers", "slow: mark test as slow to run")


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")
for item in items:
if "slow" in item.keywords:
item.add_marker(skip_slow)


@pytest.fixture(scope="session")
Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ passenv =
# {posargs} can be passed in by additional arguments specified when invoking tox.
# Can be used to specify which tests to run, e.g.: tox -- -s
commands =
coverage run --source smexperiments -m pytest {posargs} -m "not slow"
coverage run --source smexperiments -m pytest {posargs}
{env:IGNORE_COVERAGE:} coverage report --fail-under=95
extras = test
deps =
Expand Down Expand Up @@ -95,7 +95,7 @@ passenv =
# {posargs} can be passed in by additional arguments specified when invoking tox.
# Can be used to specify which tests to run, e.g.: tox -- -s
commands =
pytest {posargs} --verbose -m "slow" --capture=no
pytest {posargs} --verbose --runslow --capture=no
extras = test
deps =
boto3 >= 1.10.32
Expand Down

0 comments on commit 9570493

Please sign in to comment.