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.


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.



...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
Radiolab by WNYC Studios

Radiolab

43,838 Listeners

Software Engineering Daily by Software Engineering Daily

Software Engineering Daily

623 Listeners

Heavy Networking by Packet Pushers

Heavy Networking

327 Listeners

Talk Python To Me by Michael Kennedy

Talk Python To Me

585 Listeners

Python Bytes by Michael Kennedy and Brian Okken

Python Bytes

215 Listeners

Darknet Diaries by Jack Rhysider

Darknet Diaries

8,035 Listeners

The Real Python Podcast by Real Python

The Real Python Podcast

142 Listeners

Unexplainable by Vox

Unexplainable

2,308 Listeners

Network Automation Nerds by Packet Pushers

Network Automation Nerds

3 Listeners