Skip to content

Commit

Permalink
fix linter
Browse files Browse the repository at this point in the history
  • Loading branch information
svidiella committed Feb 27, 2024
1 parent 98fc363 commit 1b62d88
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions libs/vertexai/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"""

from typing import List
import pytest

import pytest

_RELEASE_FLAG = "release"
_GPU_FLAG = "gpu"
Expand All @@ -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:
Expand All @@ -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.
Expand All @@ -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)

0 comments on commit 1b62d88

Please sign in to comment.