Skip to content Skip to sidebar Skip to footer
Showing posts with the label Mocking

How Does @mock.patch Know Which Parameter To Use For Each Mock Object?

Looking at this webpage: http://www.toptal.com/python/an-introduction-to-mocking-in-python -- The a… Read more How Does @mock.patch Know Which Parameter To Use For Each Mock Object?

Mocking File Objects Or Iterables In Python

Which way is proper for mocking and testing code that iters object returned by open(), using mock l… Read more Mocking File Objects Or Iterables In Python

Python Patch Object With A Side_effect

I'm trying to have a Mock object return certain values based on the input given. I looked up a … Read more Python Patch Object With A Side_effect

How Can I Mock Any Function Which Is Not Being Called Directly?

TL;DR How can I patch or mock 'any functions that are not being called/used directly'? Scen… Read more How Can I Mock Any Function Which Is Not Being Called Directly?

How Do We Ensure That The Calls In The Mock.call_args_list Contain Calls With Arguments At The Same State Of When The Mock Object Was Called?

from mock import Mock j = [] u = Mock() u(j) # At this point u.call_args_list == [call([])] print u… Read more How Do We Ensure That The Calls In The Mock.call_args_list Contain Calls With Arguments At The Same State Of When The Mock Object Was Called?

Running Pytest Tests Against Multiple Backends?

I've built a series of tests (using pytest) for a codebase interacting with the Github API (bot… Read more Running Pytest Tests Against Multiple Backends?