Willison highlights pytest's subtests as a new feature. He found subtests to be potentially better than pytest.mark.parametrize. The author used Claude Code to convert tests to use subtests.
Full Analysis
• Willison discusses the subtests feature in pytest 9.0.0, which he found interesting, especially since he's a "big user of the pytest.mark.parametrize decorator." This shows a direct interest in alternative testing methods.
• The core innovation lies in the comparison between using pytest.mark.parametrize and the new subtests. The author provides code examples, illustrating how tests can be refactored to use subtests instead, and why this method is better.
• Willison points out two advantages: subtests might run faster and offer the flexibility to be created programmatically after setup, while he also used Claude Code to assist in porting tests, showcasing the integration of AI-assisted programming.
Rate this article: