From a57dd90a49ac54af86c6264b985a579d14acb27c Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 23 May 2024 15:02:31 -0700 Subject: [PATCH] fix unicode err --- tests/test_io.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/tests/test_io.py b/tests/test_io.py index d7adc5ee0..f639563f3 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -1,7 +1,7 @@ import os import unittest from pathlib import Path -from unittest.mock import patch, MagicMock +from unittest.mock import MagicMock, patch from aider.io import AutoCompleter, InputOutput from aider.utils import ChdirTemporaryDirectory @@ -43,23 +43,20 @@ class TestInputOutput(unittest.TestCase): autocompleter = AutoCompleter(root, rel_fnames, addable_rel_fnames, commands, "utf-8") 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): - # Set the environment variable to ensure UTF-8 encoding - os.environ["PYTHONIOENCODING"] = "utf-8" - # Mock the PromptSession to simulate user input mock_session = MockPromptSession.return_value mock_session.prompt.return_value = "test input" - io = InputOutput() + io = InputOutput(pretty=False) # Windows tests throw UnicodeDecodeError root = "/" rel_fnames = ["existing_file.txt"] addable_rel_fnames = ["new_file.txt"] commands = MagicMock() # 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) self.assertEqual(result, "test input")