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:
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.
Enter the URL of a public GitHub repository