title: Pytest - mocking class instance passed as an argument
body: <p>Let's say I have a simplified class <code>Object</code>:</p>
  <pre><code>class Object:
      def __init__(self, data):
          self.data = data
  
      def get_data():
          return data.copy()
  </code></pre>
  <p>And freestanding function <code>foo</code>:</p>
  <pre><code>def foo(obj: Object):
      copied_data = obj.get_data()
      ...
  </code></pre>
  <p>I want to test <code>foo</code> and use a fixture with mocked <code>Object</code> instance to pass as the argument to <code>foo</code>. I want the mocked object to return some predefined data so I need to mock its method as well.</p>
  <p>How should I do this in a &quot;proper&quot; way with pytest? I'm not sure how to combine mocks and fixtures.</p>