From 4539e3170114714218264485629d7f571c3a49bf Mon Sep 17 00:00:00 2001 From: Varac <varac@varac.net> Date: Thu, 29 Jul 2021 15:49:12 +0200 Subject: [PATCH] Add --namespace fixture to pytest --- test/conftest.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/test/conftest.py b/test/conftest.py index 0edcc1ac9..c865ae39b 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -2,7 +2,9 @@ import pytest def pytest_addoption(parser): - """Add option `--app` to select specific app to test. + """Add pytest options: + --app: Select specific app to test + --namespace: Use specific namespace to look for app See https://docs.pytest.org/en/stable/example/simple.html#pass-different-values-to-a-test-function-depending-on-command-line-options """ @@ -11,8 +13,18 @@ def pytest_addoption(parser): help="Name of the app to test, default: all" ) + parser.addoption( + "--namespace", action="store", default="", + help="Namespace of the app to test, default: <empty>" + ) + @pytest.fixture def app(request): """Process new cli option.""" return request.config.getoption("--app") + +@pytest.fixture +def namespace(request): + """Process new cli option.""" + return request.config.getoption("--namespace") -- GitLab