Creating a More Complex Test

Let's explore how we can create a more complex test using unittest module.

Most of the codes are more complex than our my_math.py example. So let’s create a piece of code that depends on a database being in existence. We will create a simple script that can create the database with some initial data if it doesn’t exist along with a few functions that will allow us to query it, delete and update rows. We will name this script simple_db.py.

Creating a script

This is a fairly long example, so bear with us:

Get hands-on with 1200+ tech skills courses.