mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-25 01:44:28 +01:00
Move path argument sanitization for commands to a decorator (#4918)
* Move path argument sanitization for commands to a decorator * Fix tests * Add `@functools.wraps` to `@sanitize_path_arg` decorator Co-authored-by: James Collins <collijk@uw.edu> --------- Co-authored-by: James Collins <collijk@uw.edu>
This commit is contained in:
committed by
GitHub
parent
050c52a008
commit
c562fbf4bc
@@ -1,5 +1,6 @@
|
||||
import os
|
||||
import random
|
||||
import re
|
||||
import string
|
||||
import tempfile
|
||||
|
||||
@@ -88,13 +89,9 @@ def test_execute_python_file_invalid(agent: Agent):
|
||||
|
||||
|
||||
def test_execute_python_file_not_found(agent: Agent):
|
||||
assert all(
|
||||
s in sut.execute_python_file("notexist.py", agent).lower()
|
||||
for s in [
|
||||
"python: can't open file 'notexist.py'",
|
||||
"[errno 2] no such file or directory",
|
||||
]
|
||||
)
|
||||
result = sut.execute_python_file("notexist.py", agent).lower()
|
||||
assert re.match(r"python: can't open file '([A-Z]:)?[/\\\-\w]*notexist.py'", result)
|
||||
assert "[errno 2] no such file or directory" in result
|
||||
|
||||
|
||||
def test_execute_shell(random_string: str, agent: Agent):
|
||||
|
||||
Reference in New Issue
Block a user