Skip to content

Commit e1e8deb

Browse files
committed
Fix test collection
1 parent 2123b52 commit e1e8deb

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

tests/conftest.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -335,22 +335,23 @@ def pytest_configure(config: pytest.Config) -> None:
335335
def pytest_collection_modifyitems(
336336
config: pytest.Config, items: list[pytest.Item]
337337
) -> None:
338-
if config.getoption("--run-api-tests"):
339-
return
340-
if config.getoption("--run-cluster-tests"):
341-
return
338+
# Check each flag independently
339+
run_api_tests = config.getoption("--run-api-tests")
340+
run_cluster_tests = config.getoption("--run-cluster-tests")
342341

343-
# Otherwise skip all tests requiring an API key
342+
# Create skip markers
344343
skip_api = pytest.mark.skip(
345344
reason="Skipping test because API keys are not provided. Use --run-api-tests to run these tests."
346345
)
347346
skip_cluster = pytest.mark.skip(
348347
reason="Skipping test because Redis cluster is not available. Use --run-cluster-tests to run these tests."
349348
)
349+
350+
# Apply skip markers independently based on flags
350351
for item in items:
351-
if item.get_closest_marker("requires_api_keys"):
352+
if item.get_closest_marker("requires_api_keys") and not run_api_tests:
352353
item.add_marker(skip_api)
353-
if item.get_closest_marker("requires_cluster"):
354+
if item.get_closest_marker("requires_cluster") and not run_cluster_tests:
354355
item.add_marker(skip_cluster)
355356

356357

0 commit comments

Comments
 (0)