From the course: Python Data Analytics: From Notebooks to Production

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Why testing is important

Why testing is important

- [Miki] Let's talk about testing and why it's important. The first thing the tests are doing is making sure that your code is confirming to the spec, that the code is working the way it's intended to work. The second thing is it gives you a safety net. So every time you make a change, you might add a new feature, but unintentionally, you can break something else, and then the test will tell you, "Hey, you broke something there. Go and fix that." And testing is a balance between pain and gain. The pain is the pain of writing tests. The gain is the errors that you're going to eliminate. And if your users are finding your errors, this is a high cost, so you need to play with this gain to know exactly what's going on there. We are going to focus on pytest. This is a well mature, widely used testing framework, but apart from testing, you can also help yourself by writing what is known as a linter. Linters are static code analyzers that run before the test. One of them, for example, is…

Contents