diff --git a/tests/basic/test_find_or_blocks.py b/tests/basic/test_find_or_blocks.py index 483414a5e..5cff18f8d 100755 --- a/tests/basic/test_find_or_blocks.py +++ b/tests/basic/test_find_or_blocks.py @@ -1,10 +1,10 @@ #!/usr/bin/env python3 -import re -import sys +import difflib import io import os -import difflib +import re +import sys import unittest from aider.coders.base_coder import all_fences @@ -65,24 +65,24 @@ def process_markdown(filename, fh): class TestFindOrBlocks(unittest.TestCase): def test_process_markdown(self): # Path to the input markdown file - input_file = 'tests/fixtures/chat-history.md' - + input_file = "tests/fixtures/chat-history.md" + # Path to the expected output file - expected_output_file = 'tests/fixtures/chat-history-search-replace-gold.txt' - + expected_output_file = "tests/fixtures/chat-history-search-replace-gold.txt" + # Create a StringIO object to capture the output output = io.StringIO() - + # Run process_markdown process_markdown(input_file, output) - + # Get the actual output actual_output = output.getvalue() - + # Read the expected output - with open(expected_output_file, 'r') as f: + with open(expected_output_file, "r") as f: expected_output = f.read() - + # Compare the actual and expected outputs if actual_output != expected_output: # If they're different, create a diff @@ -90,15 +90,16 @@ class TestFindOrBlocks(unittest.TestCase): expected_output.splitlines(keepends=True), actual_output.splitlines(keepends=True), fromfile=expected_output_file, - tofile='actual output' + tofile="actual output", ) - + # Join the diff lines into a string - diff_text = ''.join(diff) - + diff_text = "".join(diff) + # Fail the test and show the diff self.fail(f"Output doesn't match expected output. Diff:\n{diff_text}") + if __name__ == "__main__": if len(sys.argv) != 2: print("Usage: python testsr.py ")