Skipping Tests With pytest

Learn how to skip Python tests using pytest module.

We'll cover the following...

Overview

It is sometimes necessary to skip tests in pytest, for a similar variety of reasons: the code being tested hasn’t been written yet, the test only runs on certain interpreters or operating systems, or the test is time-consuming and should only be run under certain circumstances.

The skip() function

One way to skip tests is by using the pytest.skip() function. It accepts a single argument: a string describing why it has been skipped. This function can be called anywhere. If we call it inside a test function, the test will be skipped. If we call it at the module level, all the tests in ...