January 2019
Beginner
318 pages
8h 23m
English
In this section, we are going to create unit tests. To do this, we will create two scripts. One will be your normal script and the other will contain the code for testing.
First, create a script named arithmetic.py and write the following code in it:
# In this script, we are going to create a 4 functions: add_numbers, sub_numbers, mul_numbers, div_numbers.def add_numbers(x, y): return x + ydef sub_numbers(x, y): return x - ydef mul_numbers(x, y): return x * ydef div_numbers(x, y): return (x / y)
In the preceding script, we created four functions: add_numbers, sub_numbers, mul_numbers, and div_numbers. Now, we are going to write test cases for these functions. First, we will learn how we can write test cases for the add_numbers ...
Read now
Unlock full access