Skip to content

test: add dedicated test coverage for search_replace module#5007

Open
1Ckpwee wants to merge 1 commit intoAider-AI:mainfrom
1Ckpwee:test/add-search-replace-tests
Open

test: add dedicated test coverage for search_replace module#5007
1Ckpwee wants to merge 1 commit intoAider-AI:mainfrom
1Ckpwee:test/add-search-replace-tests

Conversation

@1Ckpwee
Copy link
Copy Markdown

@1Ckpwee 1Ckpwee commented Apr 8, 2026

Summary

The aider/coders/search_replace.py module is a core part of how aider applies code edits, but it had no dedicated test file. This PR adds comprehensive test coverage with 47 tests across 8 test classes.

Test coverage added

  • search_and_replace(): exact match, multiple occurrences, no match, multiline, unicode, special characters
  • RelativeIndenter: roundtrip for various indent patterns, marker selection logic, error cases, multi-text support
  • line_pad() / line_unpad(): roundtrip, padding structure, invalid input, edge cases
  • reverse_lines(): basic, single line, double-reverse identity
  • strip_blank_lines(): leading/trailing stripping, internal preservation, trailing newline enforcement
  • flexible_search_and_replace(): strategy selection, preprocessing interaction
  • try_strategy(): with and without preprocessing, failure paths
  • dmp_apply(): identical input, complete mismatch
  • Edge cases: empty strings, whitespace-only, newlines-only, tabs, unicode

Test plan

  • All 47 tests pass locally (pytest tests/basic/test_search_replace.py -v — 0.48s)
  • CI validation

Covers search_and_replace, RelativeIndenter, line_pad/unpad,
reverse_lines, strip_blank_lines, flexible_search_and_replace,
try_strategy, dmp_apply, and various edge cases (unicode, whitespace,
empty strings, tabs, special characters).
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 8, 2026

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants