paint-brush
Python Cheatsheet: Mock Object Libraryby@camposer
1,626 reads
1,626 reads

Python Cheatsheet: Mock Object Library

by Rodolfo CamposOctober 3rd, 2021
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

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.
featured image - Python Cheatsheet: Mock Object Library
Rodolfo Campos HackerNoon profile picture
Rodolfo Campos

Rodolfo Campos

@camposer

L O A D I N G
. . . comments & more!

About Author

Rodolfo Campos HackerNoon profile picture
Rodolfo Campos@camposer

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite