MCPcopy Create free account
hub / github.com/ScrapeGraphAI/Scrapegraph-ai / pytest_collection_modifyitems

Function pytest_collection_modifyitems

tests/conftest.py:388–412  ·  view source on GitHub ↗

Modify test collection based on markers and CLI options.

(config, items)

Source from the content-addressed store, hash-verified

386
387
388def pytest_collection_modifyitems(config, items):
389 """Modify test collection based on markers and CLI options."""
390 skip_integration = pytest.mark.skip(reason="use --integration to run")
391 skip_slow = pytest.mark.skip(reason="use --slow to run")
392 skip_requires_api = pytest.mark.skip(reason="requires API keys")
393
394 for item in items:
395 # Skip integration tests unless --integration flag is passed
396 if "integration" in item.keywords and not config.getoption("--integration", default=False):
397 item.add_marker(skip_integration)
398
399 # Skip slow tests unless --slow flag is passed
400 if "slow" in item.keywords and not config.getoption("--slow", default=False):
401 item.add_marker(skip_slow)
402
403 # Skip tests requiring API keys if keys are not set
404 if "requires_api_key" in item.keywords:
405 # Check if any API key is available
406 has_api_key = any([
407 os.getenv("OPENAI_APIKEY"),
408 os.getenv("ANTHROPIC_APIKEY"),
409 os.getenv("GROQ_APIKEY"),
410 ])
411 if not has_api_key:
412 item.add_marker(skip_requires_api)
413
414
415def pytest_addoption(parser):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected