-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
This is a meta issue to describe ongoing attention that should be devoted to tests. I don't want anyone to do this in a single commit or even a single PR, it's something that anyone can pick up one file, or even one part of a file, at a time. The later tasks about reorganizing will be easier once the earlier tasks are done, but will still require a good amount of familiarity and planning.
The tests in Pallets projects slowly evolved from using unittest to using pytest, and were also contributed by many users over time, so the style and organization are often inconsistent. The goal is to eventually have all tests organized into smaller, specific files to make it easier for contributors to identify where to add a new test.
- Replace for loops with
pytest.mark.parametrize. - Replace repeated groups of asserts in one test with
parametrize. - Refactor separate, similar test functions into a single parametrized function. Don't go overboard, sometimes it's easier to read when functions are kept separate.
- Remove class-based tests. If the class was used to group tests for a distinct function, consider moving all the tests to a separate file.
- Make sure test names follow the pattern
test_{function}_{behavior}. - Split up large test files into multiple, more specific files.
- Rearrange tests to group similar functions / behaviors together or move into specific files.
- Run
coverage run -m pytestto identify missing coverage and write tests (or add parametrize cases to existing tests).
Anyone can help contribute to this effort. Pick a file or function to work on, and make a PR for it. Again, don't do all bullet points in a single commit, and don't do too much in one PR, otherwise it will be harder to review.