Skip to content

Commit

Permalink
test(patch): improve empty patch test
Browse files Browse the repository at this point in the history
- Remove debug print statements
- Simplify assertion by comparing line counts instead of checking string patterns
- Remove outdated note about UPDATED block requirements
- Fix empty patch handling by ensuring line count is preserved (minus the removed line)
  • Loading branch information
ErikBjare committed Nov 22, 2024
1 parent 7c51573 commit a660512
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions tests/test_tools_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,15 @@ def hello():
hello()
"""

# NOTE: test fails if UPDATED block doesn't have an empty line
codeblock = """
<<<<<<< ORIGINAL
def hello():
print("hello")
=======
>>>>>>> UPDATED
"""
print(content)
result = apply(codeblock, content)
newline = "\n"
newline_escape = "\\n"
assert result.startswith(
"\n\n"
), f"result: {result.replace(newline, newline_escape)}"
assert result.count("\n") == content.count("\n") - 1


def test_apply_empty_lines():
Expand Down

0 comments on commit a660512

Please sign in to comment.