diff --git a/libs/vertexai/tests/conftest.py b/libs/vertexai/tests/conftest.py index 7aee5c08..e24337c7 100644 --- a/libs/vertexai/tests/conftest.py +++ b/libs/vertexai/tests/conftest.py @@ -3,8 +3,8 @@ """ from typing import List -import pytest +import pytest _RELEASE_FLAG = "release" _GPU_FLAG = "gpu" @@ -26,7 +26,12 @@ def pytest_addoption(parser: pytest.Parser) -> None: :return: """ for flag in _PYTEST_FLAGS: - parser.addoption(f"--{flag}", action="store_true", default=False, help=f"run {flag} tests") + parser.addoption( + f"--{flag}", + action="store_true", + default=False, + help=f"run {flag} tests" + ) def pytest_configure(config: pytest.Config) -> None: @@ -36,10 +41,16 @@ def pytest_configure(config: pytest.Config) -> None: :return: """ for flag in _PYTEST_FLAGS: - config.addinivalue_line("markers", f"{flag}: mark test to run as {flag} only test") + config.addinivalue_line( + "markers", + f"{flag}: mark test to run as {flag} only test" + ) -def pytest_collection_modifyitems(config: pytest.Config, items: List[pytest.Item]) -> None: +def pytest_collection_modifyitems( + config: pytest.Config, + items: List[pytest.Item] +) -> None: """ Skip tests with a marker from our list that were not explicitly invoked. :param config: The pytest config object. @@ -48,5 +59,6 @@ def pytest_collection_modifyitems(config: pytest.Config, items: List[pytest.Item """ for item in items: keywords = list(set(item.keywords).intersection(_PYTEST_FLAGS)) - if keywords and not any((config.getoption(f"--{keyword}") for keyword in keywords)): - item.add_marker(pytest.mark.skip(reason=f"need --{keywords[0]} option to run")) + if keywords and not any((config.getoption(f"--{kw}") for kw in keywords)): + skip = pytest.mark.skip(reason=f"need --{keywords[0]} option to run") + item.add_marker(skip)