diff --git a/python_files/vscode_pytest/__init__.py b/python_files/vscode_pytest/__init__.py index ca06bf174418..028839b13212 100644 --- a/python_files/vscode_pytest/__init__.py +++ b/python_files/vscode_pytest/__init__.py @@ -67,6 +67,13 @@ def __init__(self, message): def pytest_load_initial_conftests(early_config, parser, args): # noqa: ARG001 + has_pytest_cov = early_config.pluginmanager.hasplugin("pytest_cov") + has_cov_arg = any("--cov" in arg for arg in args) + if has_cov_arg and not has_pytest_cov: + raise VSCodePytestError( + "\n \nERROR: pytest-cov is not installed, please install this before running pytest with coverage as pytest-cov is required. \n" + ) + global TEST_RUN_PIPE TEST_RUN_PIPE = os.getenv("TEST_RUN_PIPE") error_string = (