mirror of
https://github.com/leonvanzyl/autocoder.git
synced 2026-01-30 14:22:04 +00:00
fix: rename test_hook to check_hook to fix pytest fixture error
The test_hook helper function was being incorrectly interpreted by pytest as a test function due to the 'test_' prefix. Pytest attempted to inject fixtures for its parameters (command, should_block), causing an error. Changes: - Renamed test_hook() to check_hook() in test_security.py - Updated all call sites (lines 206 and 276) - Updated docstring to clarify it's a helper function This fixes the "fixture 'command' not found" error when running pytest. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -18,8 +18,8 @@ from security import (
|
||||
)
|
||||
|
||||
|
||||
def test_hook(command: str, should_block: bool) -> bool:
|
||||
"""Test a single command against the security hook."""
|
||||
def check_hook(command: str, should_block: bool) -> bool:
|
||||
"""Check a single command against the security hook (helper function)."""
|
||||
input_data = {"tool_name": "Bash", "tool_input": {"command": command}}
|
||||
result = asyncio.run(bash_security_hook(input_data))
|
||||
was_blocked = result.get("decision") == "block"
|
||||
@@ -203,7 +203,7 @@ def main():
|
||||
]
|
||||
|
||||
for cmd in dangerous:
|
||||
if test_hook(cmd, should_block=True):
|
||||
if check_hook(cmd, should_block=True):
|
||||
passed += 1
|
||||
else:
|
||||
failed += 1
|
||||
@@ -273,7 +273,7 @@ def main():
|
||||
]
|
||||
|
||||
for cmd in safe:
|
||||
if test_hook(cmd, should_block=False):
|
||||
if check_hook(cmd, should_block=False):
|
||||
passed += 1
|
||||
else:
|
||||
failed += 1
|
||||
|
||||
Reference in New Issue
Block a user