Skip to content
Snippets Groups Projects
conftest.py 872 B
Newer Older
Varac's avatar
Varac committed
import pytest


def pytest_addoption(parser):
    """Add pytest options:
       --resource: Select specific resource to test
       --namespace: Use specific namespace to look for resource
Varac's avatar
Varac committed

    See https://docs.pytest.org/en/stable/example/simple.html#pass-different-values-to-a-test-function-depending-on-command-line-options
    """
    parser.addoption(
        "--resource", action="store", default="all",
        help="Name of the resource to test, default: all"
    parser.addoption(
        "--namespace", action="store", default="",
        help="Namespace of the resource to test, default: <empty>"
Varac's avatar
Varac committed

@pytest.fixture
def resource(request):
Varac's avatar
Varac committed
    """Process new cli option."""
    return request.config.getoption("--resource")

@pytest.fixture
def namespace(request):
    """Process new cli option."""
    return request.config.getoption("--namespace")