title: How to trigger a code segment when a certain function is called for testing in python
body: <p>My system has a long and complicated flow to it. For simplicity's sake, lets say it looks like this:</p>
  <pre><code>def main():
   function_1()
   function_2()
   .
   .
   function_n()
  </code></pre>
  <p>I want to create a unit test that will trigger on a certain function, e.g:</p>
  <pre><code>def test():
    main()
    function_3.called():  # need help with this line
      some_code()
  </code></pre>
  <p>Is there a way to accomplish this using Pytest?</p>