title: How to permanently mock return value of a function in python unittest
body: <p>I have a function</p>
  
  <pre><code># foo.py
  NUM_SHARDS = 10
  def get_shard(shard_key: int) -&gt; int
      return (shard_key % NUM_SHARDS) + 1
  </code></pre>
  
  <p>I want to mock this function such that whenever this function is called, it returns a certain value. I've tried patching like such</p>
  
  <pre><code># test.py
  @mock.patch('foo.get_shard', return_value=11)
      def testSomething(self, patched_func):
          patched_func() # &gt;&gt; 11 ... OK so this is fine but
          get_shard(4) # &gt;&gt; 5 .... Original impl being executed
  </code></pre>
  
  <p>I want to deeply modify this function to always return this value, whether this function is called directly from the unittest or not. </p>
  
  <p>For context, I have a number of production shards (10) and one test shard (11). The get_shard function is called in numerous and the production version of the function is only aware of 10 shards. So, I would like for this function to always return 11 (test shard number) when executed in the context of a unit test. </p>