How do I check if a function is being called by a method?
<p>How do I check if a function b() is being called by a method?</p>

<pre><code>class hello():
    delete():
        b()
</code></pre>

<p>I want to use mock in a unit test.</p>

<p>If you are just looking for a way to mock objects <a href="https://docs.python.org/3/library/unittest.mock.html" rel="nofollow">this</a> is probably the best way to do it.</p>

<p>To answer the first part of your question, there is indeed a way to get information about the caller function. <a href="https://stackoverflow.com/questions/2529859/get-parent-function">This</a> might help you</p>

python django python-2.7 mocking