Sending some values through a function and checking the output to make sure it’s correct is a common pattern in software testing. However, calling a function once with one set of values and one check for correctness isn’t enough to fully test most functions. Parametrized testing is a way to send multiple sets of data through the same test and have pytest report if any of the sets failed.
To help understand the problem parametrized testing is trying to solve, let’s take a simple test for add():
|||from tasks import Task|
|||"""tasks.get() using id returned from add() works."""|
|||task = Task('breathe', 'BRIAN', True) ...|