How do I mock a function that is defined within another function in python pytest with magic mock framework?

70 views Asked by At

Considering the following peace of code:

class X:
   def func_a(a):
      //function does somthing
      def func_b(b):
         // do something
      func_b(a)

How can I mock function func_b(a) in my test?

with patch('x.func_a.func_b', side_effect=mock_func_b)

Does not work. I am only able to mock func_a. How can I handle this issue?

0

There are 0 answers