A Simple Example of unittest Module
Explore how to use Python's unittest module to write and run simple test cases that validate functions. Understand how to organize tests, use assertions, and interpret test results to ensure your code behaves as expected.
We'll cover the following...
We'll cover the following...
We always find a code example or two to be the quickest way to learn how
something new works. So let’s create a little module that we will call
mymath.py. Then put the following code into it:
This module defines four mathematical functions: add, subtract, multiply
and divide. They do not do any error checking and they actually don’t do
exactly what we might expect. For example, if we were to call the
add function with two strings, it would happily concatenate ...