From the course: Unit Testing in Python
Unlock the full course today
Join today to access over 24,900 courses taught by industry experts.
Sad path testing - Python Tutorial
From the course: Unit Testing in Python
Sad path testing
- [Instructor] When creating unit tests, we don't want to forget sad path tests, also known as negative case tests. Let's create a sad path test that demonstrates the validation capabilities within the CSV reader on lines 9 through 11. In the resources folder, you'll find a malformed CSV file. This file contains strings in one of the three columns we want to convert to a float. For instance, on line 2 for Cape Verde, you'll see that its altitude value is indeed a string. The same for India on line 3, its latitude value is a value that can't be cast. We can then write a new test that references this malformed file. In this video, we'll primarily show how to create tests that anticipate exceptions or errors. Doing this shares important information you may find while developing with others on your team. Within the example, you'll notice a city_list_location_malformed function. This function is called within our test to supply a CSV path. Above it, you'll see the annotation…