Mocking Methods On An Instance Variable In Python
I'm trying to figure out how to properly Mock an instance variable which is an instance of another class that has methods used by the parent class. Here's a simplified example of t
Solution 1:
Can be done by mock the action return value
class TestHandler(unittest.TestCase):
@mock.patch('__main__.Client.action')
def test_example_client_action_false(self, mock_client_action):
"""Test Example When Action is False"""
mock_client_action.return_value = False
handler = Handler()
self.assertFalse(handler.example())
Post a Comment for "Mocking Methods On An Instance Variable In Python"