Top "Magicmock" questions

MagicMock is a subclass of Mock with default implementations of most of the magic methods.

Python returns MagicMock object instead of return_value

I have a python file a.py which contains two classes A and B. class A(object): def method_a(…

python python-unittest magicmock
Magic mock assert_called_once vs assert_called_once_with weird behaviour

I am noticing a weird behavior with assert_called_once and assert_called_once_with in python. This is my …

python unit-testing magicmock
Mock entire python class

I'm trying to make a simple test in python, but I'm not able to figure it out how to accomplish …

python unit-testing magicmock
mock file open in python

I'm trying to mock file open, and all of the examples show that I need to @patch('open', create=True) …

python unit-testing mocking magicmock
Mocking a imported function with pytest

I would like to test a email sending method I wrote. In file, format_email.py I import send_email. …

python mocking pytest magicmock
Comparing integer to MagicMock not working inside unittest in python

I have a class, which use a class variable to choose which logic to execute. #in file1: class SomeHelper(): def __…

python mocking python-unittest magicmock
python check if a method is called without mocking it away

class A(): def tmp(self): print("hi") def b(a): a.tmp() To check if tmp method is called in …

python python-3.x unit-testing mocking magicmock