I am trying to use the unitttest mock
framework (python 3.4.9) to mock one of the method in my test case. And it's failing as it doesn't return the mocked value.
This is the simplest example. In my case I can't change the way method being invoked.
mock method
def patch_this_method():
return 100
Test Case
import unittest
from unittest.mock import patch
from libs.util import patch_this_method
import libs
class TestLibs(unittest.TestCase):
@patch('libs.util.patch_this_method', return_value="200")
def test_1(self, *mock):
# return 200
print(libs.util.patch_this_method())
# this returns 100, original value
print(patch_this_method())