diff --git a/conftest.py b/conftest.py index 90b653146f..328d45d351 100644 --- a/conftest.py +++ b/conftest.py @@ -24,6 +24,7 @@ def pytest_addoption(parser): def pytest_configure(config): config.addinivalue_line("markers", "integration: integration tests") config.addinivalue_line("markers", "uses_network: tests may try to download files") + _IntegrationTestSpeedups.disable_plugins_already_run(config) collect_ignore = [ @@ -47,9 +48,25 @@ def pytest_configure(config): @pytest.fixture(autouse=True) def _skip_integration(request): - running_integration_tests = request.config.getoption("--integration") - is_integration_test = request.node.get_closest_marker("integration") - if running_integration_tests and not is_integration_test: - pytest.skip("running integration tests only") - if not running_integration_tests and is_integration_test: - pytest.skip("skipping integration tests") + _IntegrationTestSpeedups.conditional_skip(request) + + +class _IntegrationTestSpeedups: + """Speed-up integration tests by only running what does not run in other tests.""" + + RUNS_ON_NORMAL_TESTS = ("checkdocks", "cov", "mypy", "perf", "ruff") + + @classmethod + def disable_plugins_already_run(cls, config): + if config.getoption("--integration"): + for plugin in cls.RUNS_ON_NORMAL_TESTS: # no need to run again + config.pluginmanager.set_blocked(plugin) + + @staticmethod + def conditional_skip(request): + running_integration_tests = request.config.getoption("--integration") + is_integration_test = request.node.get_closest_marker("integration") + if running_integration_tests and not is_integration_test: + pytest.skip("running integration tests only") + if not running_integration_tests and is_integration_test: + pytest.skip("skipping integration tests")