title: Python patch.object decorator can't access method of class
body: <p>I have a test case below:</p>
  
  <pre><code>class Foo(unittest.TestCase):
  
      @staticmethod
      def my_method():
          ...
  
      def test_01(self):
  
          with patch.object(bar, 'method_to_be_mocked', side_effect=Foo.my_method):
              test_stuff()
  
  
      def test_02(self):
  
          with patch.object(bar, 'method_to_be_mocked', side_effect=Foo.my_method):
              test_stuff()
  
  
       ... ...
      def test_10(self):
  
          with patch.object(bar, 'method_to_be_mocked', side_effect=Foo.my_method):
              test_stuff()
  </code></pre>
  
  <p>Basically I'm using Foo.my_method to mock <code>method_to_be_mocked</code> The above is working fine, but as you can see I have 10 such test cases and I don't want to write "with patch.object ..." ten times. Therefore I want to use decorator and do something like this:</p>
  
  <pre><code>@patch.object(bar, 'method_to_be_mocked', side_effect=Foo.my_method):
  class Foo(unittest.TestCase):
  
      @staticmethod
      def my_method():
          ...
  
      def test_01(self):
              test_stuff()
  
  
      def test_02(self):
              test_stuff()
  
  
       ... ...
      def test_10(self):
              test_stuff()
  </code></pre>
  
  <p>But it's telling me that <code>Foo</code> is not defined?</p>