title: Use mock to patch sleep in unit test
body: <p>I have a piece of code sitting in a module like this:</p>
  
  <p>MyWorker.py:</p>
  
  <pre><code>from gevent import sleep
  
  class MyWorker(object):
    def run(self):
      for _ in range(10):
        do_something()
        sleep(1)
  </code></pre>
  
  <p>Then I want to test this while mocking sleep. I tried multiple ways of doing it but all failed. One way I thought should be working:</p>
  
  <pre><code>from mock import patch
  from x.y.z.MyWorker import MyWorker
  
  class TestWorker(unitest.testCase):
    def Test_my_worker(self):
      with patch('x.y.z.MyWorker.sleep'):
        a = MyWorker()
        a.run()
  </code></pre>