title: How to mock singleton instance methods?
body: <p>I have a module written roughyl as follows:</p>
  <pre class="lang-py prettyprint-override"><code>class __Foo:
    def __init__(self):
      self.__client = CeateClient() # a library function
  
    async def call_database(self):
      self.__client.do_thing()
  
  foo = __Foo()
  </code></pre>
  <p>This is designed so that the entire server only has one instance of this client manage, so <code>foo</code> is created once and is then used by various modules.</p>
  <p>I am required to now use <code>pytest</code> to, well, test everything, but reading online I cannot find the correct way to path this situation.
  The class method <code>call_database</code> sends an API request to a different service, which as part of the test, I want to not actually happen.
  The suggestions I see talk about patching the class method itself, but also the class is private so I couldn't really do that.</p>
  <p>The point is, when testing a function in a different module, i.e.:</p>
  <pre class="lang-py prettyprint-override"><code>from foo import foo
  
  async def bar():
    await foo.call_database()
  </code></pre>
  <p>When testing the function <code>bar</code>, I want the call to the database to not happen.
  How would I go about doing that?</p>