Python Cheatsheet: Mock Object Libraryby@camposer
1,223 reads

Python Cheatsheet: Mock Object Library

tldt arrow
Read on Terminal Reader
Read this story w/o Javascript

Too Long; Didn't Read

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.

Company Mentioned

Mention Thumbnail
featured image - Python Cheatsheet: Mock Object Library
Rodolfo Campos HackerNoon profile picture

@camposer

Rodolfo Campos


Receive Stories from @camposer

react to story with heart

RELATED STORIES

L O A D I N G
. . . comments & more!
Hackernoon hq - po box 2206, edwards, colorado 81632, usa