From ec28eff7f72ef87d065a1ef7a0815442aff382fb Mon Sep 17 00:00:00 2001 From: Hao Liu <44379968+TheRealHaoLiu@users.noreply.github.com> Date: Thu, 29 Feb 2024 14:55:02 -0500 Subject: [PATCH] Convert swagger release fixture to env var (#14940) `pytest awx/main/tests/docs --release=$(VERSION_TARGET)` where --release is required breaks test discovery and running in vscode (from within the container) --- Makefile | 2 +- awx/main/tests/docs/conftest.py | 15 +++++---------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index b49984fabc..a78e666ee7 100644 --- a/Makefile +++ b/Makefile @@ -305,7 +305,7 @@ swagger: reports @if [ "$(VENV_BASE)" ]; then \ . $(VENV_BASE)/awx/bin/activate; \ fi; \ - (set -o pipefail && py.test $(PYTEST_ARGS) awx/conf/tests/functional awx/main/tests/functional/api awx/main/tests/docs --release=$(VERSION_TARGET) | tee reports/$@.report) + (set -o pipefail && py.test $(PYTEST_ARGS) awx/conf/tests/functional awx/main/tests/functional/api awx/main/tests/docs | tee reports/$@.report) check: black diff --git a/awx/main/tests/docs/conftest.py b/awx/main/tests/docs/conftest.py index bd0cf1c99f..7ec4273627 100644 --- a/awx/main/tests/docs/conftest.py +++ b/awx/main/tests/docs/conftest.py @@ -1,13 +1,8 @@ from awx.main.tests.functional.conftest import * # noqa +import os +import pytest -def pytest_addoption(parser): - parser.addoption("--release", action="store", help="a release version number, e.g., 3.3.0") - - -def pytest_generate_tests(metafunc): - # This is called for every test. Only get/set command line arguments - # if the argument is specified in the list of test "fixturenames". - option_value = metafunc.config.option.release - if 'release' in metafunc.fixturenames and option_value is not None: - metafunc.parametrize("release", [option_value]) +@pytest.fixture() +def release(): + return os.environ.get('VERSION_TARGET', '')