Return Iterable With Mock Python

Viewed 36460

I'm trying to use Mock, to simulate a function in python. Here is my code:

    resp, content = request(...)

The request() function needs to return two values. Here's what I tried:

    with patch("syncdatetime.py") as sync_mock:
        sync_mock.request.return_value = [obj, '']

But when I run the test, I get the error "Mock object is not iterable." The request function returns an object of type Mock instead of a list. How can I patch the request function so that it returns a list?

2 Answers
Related