mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-20 20:35:00 +00:00
style: Format code and organize imports in test_editor.py
This commit is contained in:
parent
c7e9d645e5
commit
8be93b72c4
1 changed files with 7 additions and 6 deletions
|
@ -91,33 +91,34 @@ def test_discover_editor_override():
|
||||||
|
|
||||||
def test_pipe_editor_with_shell_script():
|
def test_pipe_editor_with_shell_script():
|
||||||
# Create a temporary shell script that logs its arguments
|
# Create a temporary shell script that logs its arguments
|
||||||
import tempfile
|
|
||||||
import stat
|
import stat
|
||||||
|
import tempfile
|
||||||
|
|
||||||
with tempfile.NamedTemporaryFile(mode='w', suffix='.sh', delete=False) as f:
|
with tempfile.NamedTemporaryFile(mode="w", suffix=".sh", delete=False) as f:
|
||||||
f.write('#!/bin/bash\necho "$@" > "$0.log"\n')
|
f.write('#!/bin/bash\necho "$@" > "$0.log"\n')
|
||||||
script_path = f.name
|
script_path = f.name
|
||||||
|
|
||||||
# Make the script executable
|
# Make the script executable
|
||||||
os.chmod(script_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
|
os.chmod(script_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Use the script as editor and verify it's called with .md file
|
# Use the script as editor and verify it's called with .md file
|
||||||
result = pipe_editor("test content", suffix="md", editor=script_path)
|
result = pipe_editor("test content", suffix="md", editor=script_path)
|
||||||
|
|
||||||
# Read the log file to see what arguments were passed
|
# Read the log file to see what arguments were passed
|
||||||
with open(f"{script_path}.log") as f:
|
with open(f"{script_path}.log") as f:
|
||||||
called_args = f.read().strip()
|
called_args = f.read().strip()
|
||||||
|
|
||||||
# Verify the editor was called with a .md file
|
# Verify the editor was called with a .md file
|
||||||
assert called_args.endswith(".md")
|
assert called_args.endswith(".md")
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
# Clean up
|
# Clean up
|
||||||
os.unlink(script_path)
|
os.unlink(script_path)
|
||||||
if os.path.exists(f"{script_path}.log"):
|
if os.path.exists(f"{script_path}.log"):
|
||||||
os.unlink(f"{script_path}.log")
|
os.unlink(f"{script_path}.log")
|
||||||
|
|
||||||
|
|
||||||
def test_pipe_editor():
|
def test_pipe_editor():
|
||||||
# Test with default editor
|
# Test with default editor
|
||||||
test_content = "Initial content"
|
test_content = "Initial content"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue