Deine Spracheinstellungen wurden gespeichert. Wir bilden uns ein, hier gutes Deutsch zu schreiben, aber wenn du Probleme oder gar Fehler findest, sag uns bitte Bescheid!

How to fake properly
27.04.2019 , i2
Sprache: 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.