Test & Code

111: Subtests in Python with unittest and pytest - Paul Ganssle


Listen Later

In both unittest and pytest, when a test function hits a failing assert, the test stops and is marked as a failed test.

What if you want to keep going, and check more things?

There are a few ways. One of them is subtests.

Python's unittest introduced subtests in Python 3.4.

pytest introduced support for subtests with changes in pytest 4.4 and a plugin, called pytest-subtests.
Subtests are still not really used that much.

But really, what are they? When could you use them?

And more importantly, what should you watch out for if you decide to use them?

That's what Paul Ganssle and I will be talking about today.

Special Guest: Paul Ganssle.

Sponsored By:

  • ConfigCat.com: Release features faster with less risk with ConfigCat feature flags. Promo Code: TESTANDCODE
  • WeeklyPythonExercise.com: Become a more fluent Python developer.

Links:

  • Subtests in Python — Paul's article on subtests
  • subtests in unittest - Python docs
  • pytest-subtests: plugin to support subtests in pytest
  • pytest-check: A pytest plugin that allows multiple failures per test.
★ Support this podcast on Patreon ★
...more
View all episodesView all episodes
Download on the App Store

Test & CodeBy Brian Okken

  • 4.7
  • 4.7
  • 4.7
  • 4.7
  • 4.7

4.7

70 ratings


More shows like Test & Code

View all
Software Engineering Radio - the podcast for professional software developers by se-radio@computer.org

Software Engineering Radio - the podcast for professional software developers

272 Listeners

The Changelog: Software Development, Open Source by Changelog Media

The Changelog: Software Development, Open Source

283 Listeners

Thoughtworks Technology Podcast by Thoughtworks

Thoughtworks Technology Podcast

41 Listeners

Data Skeptic by Kyle Polich

Data Skeptic

483 Listeners

Talk Python To Me by Michael Kennedy

Talk Python To Me

592 Listeners

Software Engineering Daily by Software Engineering Daily

Software Engineering Daily

624 Listeners

Soft Skills Engineering by Jamison Dance and Dave Smith

Soft Skills Engineering

269 Listeners

Python Bytes by Michael Kennedy and Brian Okken

Python Bytes

213 Listeners

Data Engineering Podcast by Tobias Macey

Data Engineering Podcast

142 Listeners

Syntax - Tasty Web Development Treats by Wes Bos & Scott Tolinski - Full Stack JavaScript Web Developers

Syntax - Tasty Web Development Treats

982 Listeners

Practical AI by Practical AI LLC

Practical AI

190 Listeners

The Stack Overflow Podcast by The Stack Overflow Podcast

The Stack Overflow Podcast

64 Listeners

The Real Python Podcast by Real Python

The Real Python Podcast

140 Listeners

Oxide and Friends by Oxide Computer Company

Oxide and Friends

47 Listeners

The Pragmatic Engineer by Gergely Orosz

The Pragmatic Engineer

52 Listeners