Back to all reviewers

Test edge cases

astral-sh/ruff
Based on 2 comments
Python

When writing tests, prioritize coverage of edge cases and non-standard code patterns to ensure robust functionality. Particularly for linting rules or code transformations, identify scenarios that might behave unexpectedly or require special handling.

Testing Python

Reviewer Prompt

When writing tests, prioritize coverage of edge cases and non-standard code patterns to ensure robust functionality. Particularly for linting rules or code transformations, identify scenarios that might behave unexpectedly or require special handling.

Include tests for:

  • Code with comments in various positions
  • Unusual formatting or line continuations
  • Nested object constructions
  • Dependencies on multiple variables
  • Different parameter passing styles (positional vs. keyword)

For example, when testing a rule that transforms string paths to Path objects:

# Test with comments in different positions
func_name( # comment
    "filename")

func_name( # comment
    "filename",
    #comment
)

# Test with line continuations
func_name \
 \
        ( # comment
        "filename",
    )

# Test with nested objects
func_name(Path("filename").resolve())

# Test with dependencies on other variables
for x, y in some_pairs:
    result.add((x, y))

Testing these edge cases early prevents subtle bugs from surfacing in production code and makes your code more maintainable over time.

2
Comments Analyzed
Python
Primary Language
Testing
Category

Source Discussions