MemotivaTesting in Python

What is the difference between Mock and MagicMock?

Testing in Python

Audio flashcard · 0:15

Nortren·

What is the difference between Mock and MagicMock?

0:15

Mock is the basic mock object that records calls and supports attribute access. MagicMock is a subclass that also provides default implementations of dunder methods, so it can be used in contexts that expect features like iteration, comparison, or context management.
docs.python.org