title: How to patch a property with mocker in pytest
body: <p>I have a project that I need to mock a property using the <code>mocker</code> fixture. Its using pytest and pytest-mock:</p>
  <pre><code>pip install pytest pytest-mock
  </code></pre>
  <p>A simple example of the problem:</p>
  <p>I have the <code>foo</code> class in the <em>foo.py</em> file:</p>
  <pre><code>class Foo:
      @property
      def bar(self):
          return &quot;x&quot;
  </code></pre>
  <p>And I have to test it mocking the property <code>bar</code>:</p>
  <pre class="lang-py prettyprint-override"><code>import foo
  
  def test_foo(mocker):
      mocker.patch(&quot;foo.Foo.bar&quot;, return_value=&quot;y&quot;)
      f = foo.Foo()
      assert f.bar == &quot;y&quot;
  </code></pre>
  <p>But when I patch it, the bar behaves like a callable and not like an attribute, how to fix this?</p>