title: pytest-mock mocker in pytest fixture
body: <p>I'm trying to find out why I don't seem to be able to use a mocked return value in a fixture.
  With the following imports</p>
  
  <pre><code>import pytest
  import uuid
  </code></pre>
  
  <p>pytest-mock example that works:</p>
  
  <pre><code>def test_mockers(mocker):
      mock_uuid = mocker.patch.object(uuid, 'uuid4', autospec=True)
      mock_uuid.return_value = uuid.UUID(hex='5ecd5827b6ef4067b5ac3ceac07dde9f')
      # this would return a different value if this wasn't the case
      assert uuid.uuid4().hex == '5ecd5827b6ef4067b5ac3ceac07dde9f'
  </code></pre>
  
  <p>The above test passes.
  However as I will be using this in many test cases I thought I could just use a fixture:</p>
  
  <pre><code>@pytest.fixture
  def mocked_uuid(mocker):
      mock_uuid = mocker.patch.object(uuid, 'uuid4', autospec=True)
      mock_uuid.return_value = uuid.UUID(hex='5ecd5827b6ef4067b5ac3ceac07dde9f')
      return mock_uuid
  
  def test_mockers(mocked_uuid):
      # this would return a different value if this wasn't the case
      assert uuid.uuid4().hex == '5ecd5827b6ef4067b5ac3ceac07dde9f'
  </code></pre>
  
  <p>The above fails with the following output:</p>
  
  <pre><code>FAILED 
  phidgetrest\tests\test_taskscheduler_scheduler.py:62 (test_mockers)
  mocked_uuid = &lt;function uuid4 at 0x0000029738C5B2F0&gt;
  
      def test_mockers(mocked_uuid):
          # this would return a different value if this wasn't the case
  &gt;       assert uuid.uuid4().hex == '5ecd5827b6ef4067b5ac3ceac07dde9f'
  E       AssertionError: assert &lt;MagicMock name='uuid4().hex' id='2848515660208'&gt; == '5ecd5827b6ef4067b5ac3ceac07dde9f'
  E        +  where &lt;MagicMock name='uuid4().hex' id='2848515660208'&gt; = &lt;MagicMock name='uuid4()' id='2848515746896'&gt;.hex
  E        +    where &lt;MagicMock name='uuid4()' id='2848515746896'&gt; = &lt;function uuid4 at 0x0000029738C5B2F0&gt;()
  E        +      where &lt;function uuid4 at 0x0000029738C5B2F0&gt; = uuid.uuid4
  
  tests\test_taskscheduler_scheduler.py:65: AssertionError
  </code></pre>
  
  <p>Hoping someone can help me understand why one works and the other doesn't or even better provide a solution that works! </p>
  
  <p>I've also tried changing the scope of the fixture[session, module, function], just in case as I don't really understand why it's failing.</p>