Skip to content

Refactor tests to avoid loops and complex logic #19

Description

@sourcery-ai

The code-quality bot has flagged the use of loops in test functions, which is discouraged according to Google's software engineering guidelines. Complex logic in tests, such as loops and conditionals, makes tests harder to reason about and less clear. To improve test clarity and maintainability, we should refactor tests to avoid loops. Suggested approaches include:

  • Using parametrized tests to eliminate loops.
  • Moving complex logic into helper functions.
  • Utilizing pytest fixtures for complex setup.

Reference: Don't Put Logic in Tests

Action items:

  • Identify all test functions containing loops.
  • Refactor these tests using the suggested approaches above.
  • Ensure tests remain clear and easy to inspect after refactoring.

I created this issue for @ajwalkiewicz from #17 (comment).

Tips and commands

Getting Help

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions