Python Unit Testing: Testing Python Code Using doctest

Python    |    Intermediate
  • 8 videos | 43m 16s
  • Includes Assessment
  • Earns a Badge
Rating 4.6 of 25 users Rating 4.6 of 25 users (25)
This 8-video course explores several Python applications for testing, including the unit-test framework, pytest, and doctest. To take this course, you should have prior experience with Python programming, and familiarity with running commands from a Linux shell. This course focuses on doctests, and examines how the doctest module allows the definition of simple python tests within the docstrings in your source code. You will examine what syntax is needed when manually running tests from a Python shell, and how to copy over shells. Next, you will learn to capture the output and use it in your source file, then how to create an executable document for your source. This course demonstrates packaging a readme file, and the tests for a Python module. Learners will examine the bundling of documentation and tests into a single executable file. You will learn how to Ellipsis directive to address unpredictable outputs. Finally, you will learn to instruct your doctests to ignore whitespace characters within the outputs of a test by using the normalized whitespace directive.

WHAT YOU WILL LEARN

  • Discover the key concepts covered in this course
    Write and execute a test using the doctest module
    Recognize where doctests can be placed within source code
    Create a readme file for a python module which bundles documentation and testing in a single file
  • Use the ellipsis directive to account for unpredictable output in doctests
    Use the ellipsis directive to check if the code raises exceptions for incorrect input values
    Recall how to set doctest to ignore whitespace in the output of tests tests
    Summarize the key concepts covered in this course

IN THIS COURSE

  • 2m 15s
  • 8m 8s
    Learn how to write and execute a test using the doctest module. FREE ACCESS
  • Locked
    3.  The Placement of doctests
    8m 16s
    After completing this video, you will be able to recognize where doctests can be placed within source code. FREE ACCESS
  • Locked
    4.  An Executable Document
    6m 56s
    In this video, learn how to create a readme file for a Python module which bundles documentation and testing in a single file. FREE ACCESS
  • Locked
    5.  Handle Unpredictable Outputs
    6m 20s
    In this video, learn how to use the ELLIPSIS directive to account for unpredictable output in doctests. FREE ACCESS
  • Locked
    6.  Test for Exceptions
    4m 1s
    During this video, you will learn how to use the ELLIPSIS directive to check if the code raises exceptions for incorrect input values. FREE ACCESS
  • Locked
    7.  Handle Whitespace in the Output
    5m 50s
    Upon completion of this video, you will be able to recall how to set doctest to ignore whitespace in the output of tests. FREE ACCESS
  • Locked
    8.  Course Summary
    1m 31s

EARN A DIGITAL BADGE WHEN YOU COMPLETE THIS COURSE

Skillsoft is providing you the opportunity to earn a digital badge upon successful completion on some of our courses, which can be shared on any social network or business platform.

Digital badges are yours to keep, forever.

PEOPLE WHO VIEWED THIS ALSO VIEWED THESE

Rating 4.3 of 627 users Rating 4.3 of 627 users (627)
Rating 4.5 of 15 users Rating 4.5 of 15 users (15)
Rating 4.5 of 49 users Rating 4.5 of 49 users (49)