Learning to test

So far in this book, we haven't covered how to create tests. Now is a good time to do that, so we are going to create tests for the methods that we created in the model manager.

Why do we need tests? The short answer to this question is that tests will allow us to know that the methods or functions are doing the right thing. The other reason (and one of the most important, in my opinion) is that tests give us more confidence when it comes to performing changes in the code.

Django has great tools out of the box for creating unit and integration tests, and combined with frameworks like Selenium, it is possible to basically test all of our application.

With that said, let's create our first tests. Django creates a file called ...

Get Python Programming Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.