From the course: Cisco DevNet Associate (200-901) Cert Prep 4: Application Deployment and Security

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Build a Python code test with unittest

Build a Python code test with unittest

From the course: Cisco DevNet Associate (200-901) Cert Prep 4: Application Deployment and Security

Start my 1-month free trial

Build a Python code test with unittest

- [Instructor] We have talked about the concept of testing. Let's look at a few examples of how to test our Python code where we'll use Python's unittest module that is included in the standard library, so no additional installations needed. However, a detailed explanation of the unittest module is outside of the scope of this class, but what is important here is to follow the workflow and the concept of code testing. So if we take a look at unittests_example_1, we could see that in Python's unittesting, we will begin by sub classing the test case from the unittest module. Then we would define our different unit tests. Each of these tests we start the word tests,, the kind of assertion it is testing for, and then the actual condition. In our example, we have five different tests. In our first test it just yields a past condition automatically. The second test is to test the failed condition by using assert false, but give…

Contents