mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-28 16:25:00 +00:00
fix unicode err
This commit is contained in:
parent
cb4384edc7
commit
a57dd90a49
1 changed files with 4 additions and 7 deletions
|
@ -1,7 +1,7 @@
|
||||||
import os
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from unittest.mock import patch, MagicMock
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
from aider.io import AutoCompleter, InputOutput
|
from aider.io import AutoCompleter, InputOutput
|
||||||
from aider.utils import ChdirTemporaryDirectory
|
from aider.utils import ChdirTemporaryDirectory
|
||||||
|
@ -43,23 +43,20 @@ class TestInputOutput(unittest.TestCase):
|
||||||
autocompleter = AutoCompleter(root, rel_fnames, addable_rel_fnames, commands, "utf-8")
|
autocompleter = AutoCompleter(root, rel_fnames, addable_rel_fnames, commands, "utf-8")
|
||||||
self.assertEqual(autocompleter.words, set(rel_fnames))
|
self.assertEqual(autocompleter.words, set(rel_fnames))
|
||||||
|
|
||||||
@patch('aider.io.PromptSession')
|
@patch("aider.io.PromptSession")
|
||||||
def test_get_input_is_a_directory_error(self, MockPromptSession):
|
def test_get_input_is_a_directory_error(self, MockPromptSession):
|
||||||
# Set the environment variable to ensure UTF-8 encoding
|
|
||||||
os.environ["PYTHONIOENCODING"] = "utf-8"
|
|
||||||
|
|
||||||
# Mock the PromptSession to simulate user input
|
# Mock the PromptSession to simulate user input
|
||||||
mock_session = MockPromptSession.return_value
|
mock_session = MockPromptSession.return_value
|
||||||
mock_session.prompt.return_value = "test input"
|
mock_session.prompt.return_value = "test input"
|
||||||
|
|
||||||
io = InputOutput()
|
io = InputOutput(pretty=False) # Windows tests throw UnicodeDecodeError
|
||||||
root = "/"
|
root = "/"
|
||||||
rel_fnames = ["existing_file.txt"]
|
rel_fnames = ["existing_file.txt"]
|
||||||
addable_rel_fnames = ["new_file.txt"]
|
addable_rel_fnames = ["new_file.txt"]
|
||||||
commands = MagicMock()
|
commands = MagicMock()
|
||||||
|
|
||||||
# Simulate IsADirectoryError
|
# Simulate IsADirectoryError
|
||||||
with patch('aider.io.open', side_effect=IsADirectoryError):
|
with patch("aider.io.open", side_effect=IsADirectoryError):
|
||||||
result = io.get_input(root, rel_fnames, addable_rel_fnames, commands)
|
result = io.get_input(root, rel_fnames, addable_rel_fnames, commands)
|
||||||
self.assertEqual(result, "test input")
|
self.assertEqual(result, "test input")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue