11import unittest
22import os
3- from patch_tool import PatchTool
3+ from tools . edit_tool import EditTool
44
55
6- class TestPatchTool (unittest .TestCase ):
6+ class TestEditTool (unittest .TestCase ):
77 def setUp (self ):
88 self .test_file = "test_file.txt"
99 with open (self .test_file , "w" ) as f :
@@ -14,19 +14,19 @@ def tearDown(self):
1414 os .remove (self .test_file )
1515
1616 def test_basic_replace (self ):
17- patch = """--- test_file.txt
17+ edit = """--- test_file.txt
1818+++ test_file.txt
1919@@ -2,1 +2,1 @@
2020-Line 2
2121+Line Two Modified
2222"""
23- new_content = PatchTool . apply_patch (self .test_file , patch )
23+ new_content = EditTool . edit (self .test_file , edit )
2424 self .assertIn ("Line Two Modified\n " , new_content )
2525 self .assertNotIn ("Line 2\n " , new_content )
2626 self .assertEqual (new_content .splitlines ()[1 ], "Line Two Modified" )
2727
2828 def test_multi_line_hunk (self ):
29- patch = """--- test_file.txt
29+ edit = """--- test_file.txt
3030+++ test_file.txt
3131@@ -3,2 +3,3 @@
3232-Line 3
@@ -35,15 +35,15 @@ def test_multi_line_hunk(self):
3535+Line Three.Five
3636+Line Four
3737"""
38- new_content = PatchTool . apply_patch (self .test_file , patch )
38+ new_content = EditTool . edit (self .test_file , edit )
3939 lines = new_content .splitlines ()
4040 self .assertEqual (lines [2 ], "Line Three" )
4141 self .assertEqual (lines [3 ], "Line Three.Five" )
4242 self .assertEqual (lines [4 ], "Line Four" )
4343 self .assertEqual (len (lines ), 6 )
4444
4545 def test_multiple_hunks (self ):
46- patch = """--- test_file.txt
46+ edit = """--- test_file.txt
4747+++ test_file.txt
4848@@ -1,1 +1,1 @@
4949-Line 1
@@ -52,7 +52,7 @@ def test_multiple_hunks(self):
5252-Line 5
5353+Last Line
5454"""
55- new_content = PatchTool . apply_patch (self .test_file , patch )
55+ new_content = EditTool . edit (self .test_file , edit )
5656 lines = new_content .splitlines ()
5757 self .assertEqual (lines [0 ], "First Line" )
5858 self .assertEqual (lines [- 1 ], "Last Line" )
0 commit comments