From the course: NetOps (DevOps for Network Engineers): Automating Networks
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Testing with pytest
From the course: NetOps (DevOps for Network Engineers): Automating Networks
Testing with pytest
- [Instructor] Let's see some examples of how we could use Pytest to validate our code as well as our network equipment. Before we can use pyts we need to install it. So we're going to install Pytest, and in the third example we're going to use with request package. So I've installed them at the same line, okay? So now we've installed them. In order for Pytest to pick up the function that we're using for testing, we have to append the function with tests. And in this case, I have two functions that we intend on using Pytest for, just for illustration purpose. We're asserting the first value here, 10, 20, 30 is equal to 10, 20, 30, the second value on the right. And here we're asserting them to not be equal. This two, 10, 20, 30, 30, 20, 10. And in the third function, because it's not prefixed with test, Pytest is not going to pick it up. So let's go ahead and run it. Pytest example one, and we could see that…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.