Skip to content

Commit 5e5a7ce

Browse files
authored
add error message for missing pytest-cov while running coverage (#24288)
this error message is more specific than the generic "doesn't recognize argument `--cov=.`" and will help point users in the right direction to knowing how to enable coverage.
1 parent 28c13a1 commit 5e5a7ce

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

python_files/vscode_pytest/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ def __init__(self, message):
6767

6868

6969
def pytest_load_initial_conftests(early_config, parser, args): # noqa: ARG001
70+
has_pytest_cov = early_config.pluginmanager.hasplugin("pytest_cov")
71+
has_cov_arg = any("--cov" in arg for arg in args)
72+
if has_cov_arg and not has_pytest_cov:
73+
raise VSCodePytestError(
74+
"\n \nERROR: pytest-cov is not installed, please install this before running pytest with coverage as pytest-cov is required. \n"
75+
)
76+
7077
global TEST_RUN_PIPE
7178
TEST_RUN_PIPE = os.getenv("TEST_RUN_PIPE")
7279
error_string = (

0 commit comments

Comments
 (0)