10.14 Unit Testing with Docstrings and doctest
A key aspect of software development is testing your code to ensure that it works correctly. Even with extensive testing, however, your code may still contain bugs. According to the famous Dutch computer scientist Edsger Dijkstra, “Testing shows the presence, not the absence of bugs.”17
Module doctest
and the testmod
Function
The Python Standard Library provides the doctest
module to help you test your code and conveniently retest it after you make modifications. When you execute the doctest
module’s testmod
function ...
Get Intro to Python for Computer Science and Data Science: Learning to Program with AI, Big Data and The Cloud 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.