Skip to content

Commit

Permalink
Disable plugins that already run on normal tests when running integra…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
abravalheri committed Apr 16, 2024
1 parent 3ca45b7 commit ded2634
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -47,9 +48,24 @@ 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")

0 comments on commit ded2634

Please sign in to comment.