Top "Python-unittest.mock" questions

mock object library (part of the Python Standard Library)

python mock assert_called_with

I'm trying to understand the assert_called_with within mock but the code I wrote throws some error. import os …

python python-unittest python-mock python-unittest.mock
Python mock call_args_list unpacking tuples for assertion on arguments

I'm having some trouble dealing with the nested tuple which Mock.call_args_list returns. def test_foo(self): def …

python unit-testing python-unittest python-unittest.mock
Python Unit Test : How to unit test the module which contains database operations?

I am using pymysql client library to connect to the real database. I have a function in module, where I …

python python-2.7 unit-testing python-unittest python-unittest.mock
Python SQLAlchemy mocking

this is a method that I made chained DB query calls. import math def get_all_keys(): db_session = DBSession() …

python unit-testing sqlalchemy python-unittest python-unittest.mock
How to mock data as request.Response type in python

I would like to write some testcase to exercise object_check in isinstance(obj, requests.Response) logic. After I create …

python python-3.x pytest python-unittest python-unittest.mock
How to mock a protected/private method in a tested method?

I have a Python Clas with 2 methods. The first, _getTemperature_() is protected and the second one is a public method. …

python unit-testing python-unittest python-unittest.mock
Python patch mock appears to be called, but assert fails

I'm using Python 2.6.6 What I'm trying to do is replace the creation of an object with a Mock, to make …

python unit-testing python-unittest python-unittest.mock