I am a python newbie and am trying to mock process.communicate method, but i do not know how to return multiple values from mock. The way i am approaching it is
with patch.object(subprocess, 'Popen', new_callable=MagicMock) as process:
process.communicate.return_value = [b'', b'']
output, error = process.communicate()
The error message i am getting is :
> output, error = process.communicate()
E ValueError: not enough values to unpack (expected 2, got 0)
Can someone please point out what wrong am i doing, i have tried returning with and without square and curly braces.
process.communicate
returns a tuple and not a list so all you need to change is to:In general in Python when you return a tuple it can be returned into a tuple pointer or unpacked to multiple values. For more info you can go here (First on Google)