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 the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.