Saturday, May 2, 2020

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

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:

Support Test & Code : Python Testing for Software Engineers

Links:

<p>In both unittest and pytest, when a test function hits a failing assert, the test stops and is marked as a failed test. </p> <p>What if you want to keep going, and check more things?<br><br> There are a few ways. One of them is subtests.</p> <p>Python&#39;s unittest introduced subtests in Python 3.4.<br><br> pytest introduced support for subtests with changes in pytest 4.4 and a plugin, called pytest-subtests.<br> Subtests are still not really used that much.</p> <p>But really, what are they? When could you use them?<br><br> And more importantly, what should you watch out for if you decide to use them?</p> <p>That&#39;s what Paul Ganssle and I will be talking about today.</p><p>Special Guest: Paul Ganssle.</p><p>Sponsored By:</p><ul><li><a href="https://configcat.com/" rel="nofollow">ConfigCat</a>: <a href="https://configcat.com/" rel="nofollow">Release features faster with less risk with ConfigCat feature flags.</a> Promo Code: TESTANDCODE</li><li><a href="https://ift.tt/2krjvFF" rel="nofollow">WeeklyPythonExercise.com</a>: <a href="https://ift.tt/2krjvFF" rel="nofollow">Become a more fluent Python developer.</a></li></ul><p><a href="https://ift.tt/2tzXV5e" rel="payment">Support Test & Code : Python Testing for Software Engineers</a></p><p>Links:</p><ul><li><a href="https://ift.tt/3c2oy5i" title="Subtests in Python" rel="nofollow">Subtests in Python</a> &mdash; Paul's article on subtests</li><li><a href="https://ift.tt/1sDGK7K" title="subtests in unittest - Python docs " rel="nofollow">subtests in unittest - Python docs </a></li><li><a href="https://ift.tt/2SrjM9S" title="pytest-subtests: plugin to support subtests in pytest" rel="nofollow">pytest-subtests: plugin to support subtests in pytest</a></li><li><a href="https://ift.tt/2VXAUWF" title="pytest-check: A pytest plugin that allows multiple failures per test." rel="nofollow">pytest-check: A pytest plugin that allows multiple failures per test.</a></li></ul>

from Planet Python
via read more

No comments:

Post a Comment

TestDriven.io: Working with Static and Media Files in Django

This article looks at how to work with static and media files in a Django project, locally and in production. from Planet Python via read...