def pytest_collection_modifyitems()

in conftest.py [0:0]


def pytest_collection_modifyitems(config, items):
    if config.getoption("with_integration_tests"):
        return

    skip_mark = pytest.mark.skip(reason="need --with-integration-tests option to run")
    for item in items:
        if "integration" in item.keywords:
            item.add_marker(skip_mark)