Python Cheatsheet: Mock Object Library

Written by camposer | Published 2021/10/03
Tech Story Tags: python | testing | programming | tdd | python-programming | python-top-story | learn-python | python-tips | web-monetization

TLDR Python is super powerful and easy to use, and tests are not an exception. The MagicMock Object Library is so different, compared to the other libraries I used before, that I took some time to write a Gist to help people understand how it works. There’s no need to use a specification/interface, as you would need for Mockito. The Gist below shows different test classes for each different functionality/possibility: TestSimple. Uses “non-defined” methods from a Magic.Mock.instance. TestReturnValue. Uses the return_value field for returning custom values.via the TL;DR App

no story

Written by camposer | Family man and tech geek - passionate about Software & Data Engineering, and Entrepreneurship
Published by HackerNoon on 2021/10/03