How to fake properly
04-27, 11:00–11:45 (Europe/Vienna), i2
Language: English

Aiming at complete code coverage by unit tests tends to be cumbersome, especially for cases where external API calls a part of the code base. Python attempts to address this issue with its unittest.mock library, appearing to be a powerful companion in replacing parts of the system under test.

First and foremost, there will be a thorough discussion of the relevant use cases implemented in Python’s unittest.mock library. To move on, I will outline how this mocking functionality can be embedded in a pytest based test suite, amongst discussing the feasibility of replacing parts of the system under test. Eventually, I will discuss examples of production code unit tests that make use of the mock object library, thereby contributing to a solid understanding of the matter.

Seasoned database engineer and Linux enthusiast who believes that Python is the tool of trade when it comes to getting rid of boring tasks.