hermes - ✅(Solved) Fix test_skill_commands symlink-unavailable skip path raises NameError [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#14995Fetched 2026-04-24 10:43:43
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Participants
Timeline (top)
labeled ×3cross-referenced ×1

Error Message

NameError: name 'pytest' is not defined

Fix Action

Fix / Workaround

Minimal reproduction

cd /Users/genie/.hermes/hermes-agent
source venv/bin/activate
python - <<'PY'
from pathlib import Path
from unittest.mock import patch
import tests.agent.test_skill_commands as t
import tempfile
with tempfile.TemporaryDirectory() as d:
    root = Path(d)
    with patch.object(Path, 'symlink_to', side_effect=OSError('no symlink')):
        t._symlink_category(root / 'skills', root / 'repo', 'linked')
PY

Suggested investigation direction

Add the missing import pytest to tests/agent/test_skill_commands.py and consider adding a tiny regression test around the helper's skip path by monkeypatching Path.symlink_to to raise.

PR fix notes

PR #15007: fix(tests): skip skill symlink tests when symlinks are unavailable

Description (problem / solution / changelog)

Summary

  • import pytest in tests/agent/test_skill_commands.py so the symlink-unavailable fallback can actually skip
  • add a focused regression test that forces Path.symlink_to() to raise and asserts _symlink_category() emits a pytest skip instead of crashing

Root cause

_symlink_category() already called pytest.skip(...) in its fallback path, but the module never imported pytest. When symlink creation failed, the helper raised NameError instead of skipping.

Fix

  • add the missing import pytest
  • cover the failure path with a dedicated regression test

Regression coverage

  • tests/agent/test_skill_commands_symlink_skip.py::test_symlink_category_skips_when_symlinks_unavailable
  • tests/agent/test_skill_commands.py

Testing

  • scripts/run_tests.sh tests/agent/test_skill_commands_symlink_skip.py::test_symlink_category_skips_when_symlinks_unavailable (RED before fix, GREEN after fix)
  • scripts/run_tests.sh tests/agent/test_skill_commands.py
  • scripts/run_tests.sh tests/agent/test_skill_commands_symlink_skip.py tests/agent/test_skill_commands.py

Closes #14995

Changed files

  • tests/agent/test_skill_commands.py (modified, +1/-0)
  • tests/agent/test_skill_commands_symlink_skip.py (added, +19/-0)

Code Example

cd /Users/genie/.hermes/hermes-agent
source venv/bin/activate
python - <<'PY'
from pathlib import Path
from unittest.mock import patch
import tests.agent.test_skill_commands as t
import tempfile
with tempfile.TemporaryDirectory() as d:
    root = Path(d)
    with patch.object(Path, 'symlink_to', side_effect=OSError('no symlink')):
        t._symlink_category(root / 'skills', root / 'repo', 'linked')
PY

---

NameError: name 'pytest' is not defined
RAW_BUFFERClick to expand / collapse

Affected files/lines

  • tests/agent/test_skill_commands.py:41-50

Why this is a bug

_symlink_category() catches OSError / NotImplementedError when symlink creation is unavailable and tries to call pytest.skip(...), but the module never imports pytest. On platforms or filesystems where symlink creation fails, the intended skip path raises NameError instead of marking the test skipped.

Minimal reproduction

cd /Users/genie/.hermes/hermes-agent
source venv/bin/activate
python - <<'PY'
from pathlib import Path
from unittest.mock import patch
import tests.agent.test_skill_commands as t
import tempfile
with tempfile.TemporaryDirectory() as d:
    root = Path(d)
    with patch.object(Path, 'symlink_to', side_effect=OSError('no symlink')):
        t._symlink_category(root / 'skills', root / 'repo', 'linked')
PY

Actual result:

NameError: name 'pytest' is not defined

Expected vs actual

  • Expected: the helper uses pytest.skip(...) and the symlink-dependent test is skipped when symlinks are unavailable.
  • Actual: the skip path crashes with NameError.

Suggested investigation direction

Add the missing import pytest to tests/agent/test_skill_commands.py and consider adding a tiny regression test around the helper's skip path by monkeypatching Path.symlink_to to raise.

extent analysis

TL;DR

The most likely fix is to add the missing import pytest statement to the tests/agent/test_skill_commands.py file.

Guidance

  • Add import pytest at the top of tests/agent/test_skill_commands.py to make the pytest module available.
  • Consider adding a regression test to verify the skip path by using unittest.mock.patch to raise an OSError when Path.symlink_to is called.
  • Review the test code to ensure that the pytest.skip call is correctly handling the case where symlink creation fails.
  • Verify that the test skips as expected when symlink creation is unavailable by running the test with the pytest module imported.

Example

import pytest
from pathlib import Path

# ... (rest of the code remains the same)

Notes

This fix assumes that the pytest module is installed and available in the test environment. If pytest is not installed, it will need to be added as a dependency.

Recommendation

Apply the workaround by adding the missing import pytest statement, as this is a straightforward fix that should resolve the issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING