Python 3
Mocking library
>>> import requests
>>> from unittest.mock import Mock
Inheriting all request methods with mock
>>> mock = Mock(spec=requests)
>>> mock.get()
<Mock name='mock.get()' id='139987415228200'>
Adding return value
>>> mail = mock.MagicMock(spec=Mail)
>>>subject = mail.method_name = "42"
Resources:
https://python-mock-tutorial.readthedocs.io/en/latest/mock.html
Mocking library
>>> import requests
>>> from unittest.mock import Mock
Inheriting all request methods with mock
>>> mock = Mock(spec=requests)
>>> mock.get()
<Mock name='mock.get()' id='139987415228200'>
Adding return value
>>> mail = mock.MagicMock(spec=Mail)
>>>subject = mail.method_name = "42"
Resources:
https://python-mock-tutorial.readthedocs.io/en/latest/mock.html