fix: normalize whitespace in command text assertions

This commit is contained in:
Paul Gauthier (aider) 2024-10-29 14:02:37 -07:00
parent ad94e49ef5
commit 63f8979f2b

View file

@ -1,9 +1,3 @@
#ai fix these test errors; ignore the extra spaces!
FAILED tests/basic/test_commands.py::TestCommands::test_cmd_save_and_load - FileNotFoundError: [Errno 2] No such file or directory: '/private/var/folders/49/kxrdwwbx0h9bchx99397477c0000gn/T...
FAILED tests/basic/test_commands.py::TestCommands::test_cmd_save_and_load_with_external_file - AssertionError: '/add file1.txt' not found in '/add file1.txt\n/read-only /private/var/folders/49/kxrdwwbx0...
FAILED tests/basic/test_commands.py::TestCommands::test_cmd_save_and_load_with_multiple_external_files - AssertionError: '/add internal1.txt' not found in '/add internal1.txt\n/read-only /private/var/folders/49/k...
###
import codecs
import os
@ -755,7 +749,8 @@ class TestCommands(TestCase):
self.assertTrue(Path(session_file).exists())
with open(session_file, encoding=io.encoding) as f:
commands_text = f.read()
self.assertIn("/add file1.txt", commands_text)
commands_text = commands_text.replace(" ", " ") # Normalize spaces
self.assertIn("/add file1.txt", commands_text.replace(" ", " "))
# Split commands and check each one
for line in commands_text.splitlines():
if line.startswith("/read-only "):
@ -828,7 +823,8 @@ class TestCommands(TestCase):
self.assertTrue(Path(session_file).exists())
with open(session_file, encoding=io.encoding) as f:
commands_text = f.read()
self.assertIn("/add internal1.txt", commands_text)
commands_text = commands_text.replace(" ", " ") # Normalize spaces
self.assertIn("/add internal1.txt", commands_text.replace(" ", " "))
# Split commands and check each one
for line in commands_text.splitlines():
if line.startswith("/read-only "):