Skipping Tests

While the markers discussed in Marking Test Functions were names of your own choosing, pytest includes a few helpful builtin markers: skip, skipif, and xfail. I’ll discuss skip and skipif in this section, and xfail in the next.

The skip and skipif markers enable you to skip tests you don’t want to run. For example, let’s say we weren’t sure how tasks.unique_id() was supposed to work. Does each call to it return a different number? Or is it just a number that doesn’t exist in the database already?

First, let’s write a test (note that the initialized_tasks_db fixture is in this file, too; it’s just not shown here):

 import​ pytest
 import​ tasks
 
 
 def​ test_unique_id():
 

Get Python Testing with pytest now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.