-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from gitautoai/hiroshi
Always correct hunk header line count.
- Loading branch information
Showing
5 changed files
with
117 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Python PyTest Workflow | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Python 3.12 | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.12 | ||
|
||
- name: Install pytest | ||
run: | | ||
pip install pytest | ||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | ||
- name: Set PYTHONPATH | ||
run: echo "PYTHONPATH=$GITHUB_WORKSPACE" >> $GITHUB_ENV | ||
|
||
- name: Run pytest | ||
run: pytest |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from utils.file_manager import correct_hunk_headers | ||
|
||
|
||
def test_correct_hunk_headers_1() -> None: | ||
"""Test the case where line counts are wrong""" | ||
diff_text = """--- a/example.txt | ||
+++ b/example.txt | ||
@@ -1,3 +1,3 @@ | ||
- old line 1 | ||
+ new line 1 | ||
- old line 2 | ||
+ new line 2""" | ||
expected_result = """--- a/example.txt | ||
+++ b/example.txt | ||
@@ -1,2 +1,2 @@ | ||
- old line 1 | ||
+ new line 1 | ||
- old line 2 | ||
+ new line 2""" | ||
assert correct_hunk_headers(diff_text=diff_text) == expected_result | ||
|
||
|
||
def test_correct_hunk_headers_2() -> None: | ||
"""Test the case where the hunk header does not have a line count""" | ||
diff_text = """--- a/example2.txt | ||
+++ b/example2.txt | ||
@@ -1 +1 @@ | ||
- old line 1 | ||
+ new line 1""" | ||
expected_result = """--- a/example2.txt | ||
+++ b/example2.txt | ||
@@ -1,1 +1,1 @@ | ||
- old line 1 | ||
+ new line 1""" | ||
assert correct_hunk_headers(diff_text=diff_text) == expected_result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters