|
14 | 14 | import multiprocessing |
15 | 15 | from datetime import datetime, timedelta |
16 | 16 | from sys import platform |
| 17 | +from typing import List |
17 | 18 |
|
18 | 19 | import pandas as pd |
19 | 20 | import pytest |
| 21 | +from _pytest.nodes import Item |
20 | 22 |
|
21 | 23 | from tests.data.data_creator import create_dataset |
22 | 24 | from tests.integration.feature_repos.repo_configuration import ( |
@@ -52,18 +54,27 @@ def pytest_addoption(parser): |
52 | 54 | ) |
53 | 55 |
|
54 | 56 |
|
55 | | -def pytest_collection_modifyitems(config, items): |
| 57 | +def pytest_collection_modifyitems(config, items: List[Item]): |
56 | 58 | should_run_integration = config.getoption("--integration") is True |
57 | 59 | should_run_benchmark = config.getoption("--benchmark") is True |
58 | | - skip_integration = pytest.mark.skip( |
59 | | - reason="not running tests with external dependencies" |
60 | | - ) |
61 | | - skip_benchmark = pytest.mark.skip(reason="not running benchmarks") |
62 | | - for item in items: |
63 | | - if "integration" in item.keywords and not should_run_integration: |
64 | | - item.add_marker(skip_integration) |
65 | | - if "benchmark" in item.keywords and not should_run_benchmark: |
66 | | - item.add_marker(skip_benchmark) |
| 60 | + |
| 61 | + integration_tests = [t for t in items if "integration" in t.keywords] |
| 62 | + if not should_run_integration: |
| 63 | + for t in integration_tests: |
| 64 | + items.remove(t) |
| 65 | + else: |
| 66 | + items.clear() |
| 67 | + for t in integration_tests: |
| 68 | + items.append(t) |
| 69 | + |
| 70 | + benchmark_tests = [t for t in items if "benchmark" in t.keywords] |
| 71 | + if not should_run_benchmark: |
| 72 | + for t in benchmark_tests: |
| 73 | + items.remove(t) |
| 74 | + else: |
| 75 | + items.clear() |
| 76 | + for t in benchmark_tests: |
| 77 | + items.append(t) |
67 | 78 |
|
68 | 79 |
|
69 | 80 | @pytest.fixture |
|
0 commit comments