Top "Python-mock" questions

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

How to exclude mock package from python coverage report using nosetests

I currently try to use the mock library to write some basic nose unittests in python. After finishing some basic …

python mocking code-coverage nose python-mock
How to mock a redis client in Python?

I just found that a bunch of unit tests are failing, due a developer hasn't mocked out the dependency to …

python unit-testing mocking python-mock
How to mock just the method inside the class

Trying to write a testcase for my class based function. This is skeleton of my class class Library(object): def …

python unit-testing methods mocking python-mock
Using python mocking library on sqlalchemy

I'm using sqlalchemy to query my databases for a project. Side-by-side, I'm new to unit testing and I'm trying to …

python unit-testing sqlalchemy mocking python-mock
Customizing unittest.mock.mock_open for iteration

How should I customize unittest.mock.mock_open to handle this code? file: impexpdemo.py def import_register(register_fn): …

python unit-testing mocking iteration python-mock
Mocking default=timezone.now for unit tests

I'm trying to write unit tests for a django app that does a lot of datetime operations. I have installed …

python django unit-testing mocking python-mock
How to mock os.walk in python with a temporary filesystem?

I'm trying to test some code that uses os.walk. I want to create a temporary, in-memory filesystem that I …

python unit-testing testing mocking python-mock
How to mock a property

I'm asking how to mock a class property in a unit test using Python 3. I've tried the following, which makes …

python python-3.x pytest python-unittest python-mock
Python testing: using a fake file with mock & io.StringIO

I'm trying to test some code that operates on a file, and I can't seem to get my head around …

python unit-testing mocking python-mock
How to mock generators with mock.patch

I have gone through the page https://docs.python.org/3/library/unittest.mock-examples.html and i see that they have …

python generator nose python-unittest python-mock