Skip to content

Commit

Permalink
add error message for missing pytest-cov while running coverage (#24288)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
eleanorjboyd authored Oct 18, 2024
1 parent 28c13a1 commit 5e5a7ce
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions python_files/vscode_pytest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down

0 comments on commit 5e5a7ce

Please sign in to comment.