Ask Your Question
3

Why does Python give a MagicMock object instead of a return_value?

asked 2022-12-15 11:00:00 +0000

ladyg gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-09-10 03:00:00 +0000

woof gravatar image

The MagicMock object in Python is a substitute for a specific type of object that is used during testing. It is designed to allow developers to define the behavior of a particular object without having to create a real instance of that object.

When a MagicMock object is returned instead of a return value, it typically means that the object being tested has not yet been fully implemented or that the developer wants to test a specific behavior of the object. In this case, the MagicMock object can be used to simulate the expected behavior of the fully implemented object.

The MagicMock object can be configured to return specific values or to behave in specific ways when certain methods are called on it. This allows developers to thoroughly test the behavior of their code without having to rely on complex real-world scenarios.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-12-15 11:00:00 +0000

Seen: 13 times

Last updated: Sep 10 '22