Skip to content

Commit 6c118be

Browse files
committed
Disable plugins that already run on normal tests when running integration
1 parent 3ca45b7 commit 6c118be

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

conftest.py

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def pytest_addoption(parser):
2424
def pytest_configure(config):
2525
config.addinivalue_line("markers", "integration: integration tests")
2626
config.addinivalue_line("markers", "uses_network: tests may try to download files")
27+
_IntegrationTestSpeedups.disable_plugins_already_run(config)
2728

2829

2930
collect_ignore = [
@@ -47,9 +48,25 @@ def pytest_configure(config):
4748

4849
@pytest.fixture(autouse=True)
4950
def _skip_integration(request):
50-
running_integration_tests = request.config.getoption("--integration")
51-
is_integration_test = request.node.get_closest_marker("integration")
52-
if running_integration_tests and not is_integration_test:
53-
pytest.skip("running integration tests only")
54-
if not running_integration_tests and is_integration_test:
55-
pytest.skip("skipping integration tests")
51+
_IntegrationTestSpeedups.conditional_skip(request)
52+
53+
54+
class _IntegrationTestSpeedups:
55+
"""Speed-up integration tests by only running what does not run in other tests."""
56+
57+
RUNS_ON_NORMAL_TESTS = ("checkdocks", "cov", "mypy", "perf", "ruff")
58+
59+
@classmethod
60+
def disable_plugins_already_run(cls, config):
61+
if config.getoption("--integration"):
62+
for plugin in cls.RUNS_ON_NORMAL_TESTS: # no need to run again
63+
config.pluginmanager.set_blocked(plugin)
64+
65+
@staticmethod
66+
def conditional_skip(request):
67+
running_integration_tests = request.config.getoption("--integration")
68+
is_integration_test = request.node.get_closest_marker("integration")
69+
if running_integration_tests and not is_integration_test:
70+
pytest.skip("running integration tests only")
71+
if not running_integration_tests and is_integration_test:
72+
pytest.skip("skipping integration tests")

0 commit comments

Comments
 (0)