Python Unit Testing: Testing Python Code Using doctest


Overview/Description
Expected Duration
Lesson Objectives
Course Number
Expertise Level



Overview/Description

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.



Expected Duration (hours)
0.7

Lesson Objectives

Python Unit Testing: Testing Python Code Using doctest

  • 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
  • Course Number:
    it_pyutpydj_04_enus

    Expertise Level
    Intermediate