O'Reilly logo

Python Testing Beginner's Guide by Daniel Arbuckle

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action skipping tests

This is an example of how to skip a test:

  1. Insert the following text into your doctest file:
    Now we're telling doctest to skip a test
    >>> 'This test would fail.' # doctest: +SKIP
    If it were allowed to run.
    
  2. Run the tests using doctest and the following screen will be displayed:
    Time for action skipping testsdoctest, controllingexample, skipping
  3. Notice that the test didn't fail, and that the number of tests that were run did not change.

What just happened?

The skip directive transformed what would have been a test, into plain text(as far as doctest is concerned). Doctest never ran the test, and in fact never counted it as a test at all.

There are several situations where skipping a test ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required