fix(tests): require pytest when probing for a virtualenv - #72447
Closed
BKStock wants to merge 1 commit into
Closed
Conversation
run_tests.sh selected a venv on the existence of bin/activate alone. A repo checkout carrying a .venv that was created for something else — or never had the dev extras installed — won the probe and the run died with a bare 'No module named pytest', even when a fully populated venv/ sat right next to it. The canonical runner was unusable and the workaround was to invoke pytest directly, which is exactly what the wrapper exists to prevent. Probe now requires 'import pytest' to succeed before a candidate is accepted, so the order (.venv, venv, ~/.hermes/hermes-agent/venv) expresses preference rather than a hard first-match. Candidates that exist but lack pytest are reported on stderr along with the venv actually chosen, and when nothing qualifies the error names every path tried plus the pip command to fix it. Verified against a checkout whose .venv has no pytest: previously 0 tests collected, now 32 passed via the wrapper.
This was referenced Jul 27, 2026
Contributor
|
Thanks for the clear reproduction and targeted test-runner fix. This is an automated hermes-sweeper review; current
Closing as implemented on main. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
scripts/run_tests.shpicks a virtualenv on the existence ofbin/activatealone:A checkout carrying a
.venvthat was created for something else — or that never had the dev extras installed — wins the probe and the run dies with a bareNo module named pytest, even when a fully populatedvenv/sits right next to it. The probe order reads like a preference list but behaves as a hard first-match.Observed on a checkout with both directories present:
Note the summary reports 0 failed — the run looks green at a glance. The practical workaround is to call
pytestdirectly, which is exactly what this wrapper exists to prevent.Change
A candidate now has to prove
import pytestsucceeds before it is accepted, so the order expresses preference rather than first-match. Two diagnostics come with it:pip install -e '.[dev]'command to fix itVerification
Same checkout, after the change:
Both failure paths exercised against scratch directories:
bash -nclean.