Top "Python-mock" questions

A test utility that patches objects with user-defined code or data.

Any way to reset a mocked method to its original state? - Python Mock - mock 1.0b1

I have the following simplified class I'm mocking: class myClass(object): @staticmethod def A(): #... def check(self): #code... value = self.…

python mocking python-mock
Mocking async call in python 3.5

How do I mock async call from one native coroutine to other one using unittest.mock.patch? I currently have …

python python-asyncio python-mock
Mock patching from/import statement in Python

I am trying to get mock.patch to work on the following piece of sample code: from mock import patch …

python python-mock
Can't catch mocked exception because it doesn't inherit BaseException

I'm working on a project that involves connecting to a remote server, waiting for a response, and then performing actions …

python exception-handling python-requests python-3.3 python-mock
Python Mock Patch multiple methods in a class

Im trying to patch multiple methods in a class. Here is my simplified set up Hook.py is defined as …

python python-unittest python-mock
Getting an actual return value for a mocked file.read()

I'm using python-mock to mock out a file open call. I would like to be able to pass in fake …

python tdd mocking python-mock
Django tests - patch object in all tests

I need to create some kind of MockMixin for my tests. It should include mocks for everything that calls external …

python django unit-testing django-testing python-mock
Python Mock - How to get the return of a MagicMock as if it was a normal method

For example: import mock class MyClass(object): def foo(self, x, y, z): return (x, y, z) class TestMyClass(TestCase) @…

python unit-testing mocking python-unittest python-mock
Mocking file objects or iterables in python

Which way is proper for mocking and testing code that iters object returned by open(), using mock library? whitelist_data.…

python tdd mocking python-mock
Mocking only a single method on an object

I'm familiar with other mocking libraries in other languages such as Mockito in Java, but Python's mock library confuses the …

python mocking python-mock