Skip to content

Python Unit Tests Compilation

I've been studying && struggling to have a clear and easier understanding of how Unit Tests works.

I mean, the concept of Mocking, "faking" values and output results is a bit trick specially when you don't have a history with Development teams.

Sometimes the tricky part is to identify what needs to be tested, and then how to Mock the data and make assertions against it.

Below is a compilation of links for Unit Tests, Mocks and other information I found after hundreds of tabs open.

Why your mock doesn't work

A very detailed ilustration how objects and attributes behaves when inside modules. How the modules are imported in your code and how you mock them in your tests can make a huge difference.

Introduction:

Detailed How To's

Culture of Unit Testing

An approach on how to implement a culture of testing inside any IT area, from development to simple automation scripts.

Having targets and metrics to move forward with software deployment is important not only for the business but also for the IT folks.

How Mock Can Improve Your Unit Tests: Part 1

Basic Class implementation detailing the steps to mock a module, a class and its attributes. Also, an important where and when Mock objects.

How Mock Can Improve Your Unit Tests: Part 2

Moving forward with the previous link and examples, Caktus Group also provided a second part implementation for Unit Tests, showing how to control object behavior.

Python Unittest Examples: Mocking and Patching

Provides a range of examples for several test operations.

Gists

Mock Methods and Examples

Mocking Cheat Sheet

Mocking in Python

Cheat Sheet Of Python Mock

Slides with many examples