Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark slow tests #131

Merged
merged 3 commits into from
Apr 25, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
test: Add way to mark and skip slow tests
  • Loading branch information
lahdjirayhan committed Apr 24, 2022
commit 0cc8768097d0b1fcc66261c69c59cd1aa6856d4c
24 changes: 24 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,30 @@
from utils import vcr_kwargs, DEFAULT_OUTPUT_FOLDER


# Pytest configurations. Modified from
# https://docs.pytest.org/en/7.1.x/example/simple.html#control-skipping-of-tests-according-to-command-line-option

# Add option for CLI invocation
def pytest_addoption(parser):
parser.addoption(
"--skip-slow", action="store_true", default=False, help="skip slow tests"
)


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


# Skip slow tests unless --run_slow is given
def pytest_collection_modifyitems(config, items):
if config.getoption("--skip-slow"):
skip_slow = pytest.mark.skip(reason="skipped due to --skip-slow")
for item in items:
if "slow" in item.keywords:
item.add_marker(skip_slow)


# Configuration fixture for pytest-vcr
@pytest.fixture(scope="session")
def vcr_config():
Expand Down