Skip to content

Commit be5bf7e

Browse files
author
Yoshihiro Takahara
committed
Add test cases for invalid redirection paths
1 parent 25d254e commit be5bf7e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/test_shell_executor_redirections.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,21 @@ async def test_redirection_setup_errors(temp_test_dir):
104104
await executor._setup_redirects(redirects, temp_test_dir)
105105
finally:
106106
os.chmod(temp_test_dir, 0o755) # Reset permissions
107+
108+
109+
@pytest.mark.asyncio
110+
async def test_invalid_redirection_paths():
111+
"""Test invalid redirection path scenarios"""
112+
executor = ShellExecutor()
113+
114+
# Test missing path for output redirection
115+
with pytest.raises(ValueError, match="Missing path for output redirection"):
116+
executor._parse_command(["echo", "test", ">"])
117+
118+
# Test invalid redirection target (operator found)
119+
with pytest.raises(ValueError, match="Invalid redirection target: operator found"):
120+
executor._parse_command(["echo", "test", ">", ">"])
121+
122+
# Test missing path for input redirection
123+
with pytest.raises(ValueError, match="Missing path for input redirection"):
124+
executor._parse_command(["cat", "<"])

0 commit comments

Comments
 (0)