Skip to content

Use pytest's parametrize instead of subtests #248

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 24, 2025
Merged

Conversation

ghickman
Copy link
Contributor

Our use of subtests didn't remove much setup for the tests, but made it harder to target specific iterations of the tests.

Since the structure we were looping to perform the subtests fits perfectly with pytest's parametrize I've switched us to that. The main benefit here is that you can target each test now, using the test ids defined in the parametrize mark, for example, this is now a valid pytest invocation:

pytest tests/test_page_snapshots.py::test_page_html[klass-detail.html]

This format of test name will also be printed when tests fail, so a developer can see which templates failed in the output.

@ghickman ghickman requested a review from meshy April 22, 2025 13:52
@ghickman ghickman merged commit 07c43dc into main Apr 24, 2025
1 check passed
@ghickman ghickman deleted the remove-subtests branch April 24, 2025 13:22
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