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

Python Cheatsheet: Mock Object Library

by Rodolfo Campos2mOctober 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.

Company Mentioned

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

Rodolfo Campos

@camposer

Family man and tech geek - passionate about Software & Data Engineering, and Entrepreneurship

About @camposer
LEARN MORE ABOUT @CAMPOSER'S
EXPERTISE AND PLACE ON THE INTERNET.
L O A D I N G
. . . comments & more!

About Author

Rodolfo Campos HackerNoon profile picture
Rodolfo Campos@camposer
Family man and tech geek - passionate about Software & Data Engineering, and Entrepreneurship

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