Go back

Mocking with Python!

Python Programming

By Juan Norris, Python Developer at Santex

Here at Santex, we pride ourselves on delivering high quality software, and therefore testing is a big part of our day-to-day development process.

I’m currently working on a Python project that relies heavily on mock for unit tests. A few months ago, some new members who were not familiar with the mock library joined the team. As those of you who have used it may know, mock sometimes can be unintuitive, confusing and lead to “false positives” – passing tests that are not really testing anything – but it is also very useful and powerful.

So we found ourselves in the need of a way to explain this library a little bit, and that is why these slides were created.

We started with an introduction to what mock is and why should you use it. The slides are meant to be both a starting point and some best practices, because they explain the most important classes and helpers in the library, as well as how/when to use them and the common pitfalls you may run into.

Although there is not a lot of written information and this material is composed mostly of code examples, I hope this can get you started with Mocking in Python!

See Mocking in Python Presentation!

About Juan Norris. He is a Python/Django developer with experience in JavaScript (Jquery, AJAX), MySQL and PostgreSQL. Juan is continuously learning and training to investigate new technologies.