title: pytest fixture params with monkeypatch
body: <p>I am monkey patching a database connection class as a fixture.  What I want to accomplish is to have some parameters passed to my monkey patched fixture since different tests will all require the same monkeypatch but with different return values.</p>
  
  <pre><code>@pytest.fixture
  def data():
      now = datetime.datetime.now()
      data = Data(now)
      return data
  
  @pytest.fixture
  def patch_db(monkeypatch):
      class FakeDbConnection:
          def __init__(*args, **kwargs):
              pass
  
          def fetchall(self):
              return [1,2,3]
  
      monkeypatch.setattr(DbConnection, 'execute', FakeDbConnection)
  
  
  def test_get_somevalue(patch_db, data):
      userids = data.get_userids()
      assert userids == [1,2,3]
  
  def test_get_something_else(patch_db, data):
      userids = data.get_userids()
      assert userids == [6,7,8]
  </code></pre>
  
  <p>The problem I am having is that since my fetchall function only returns [1,2,3].  I tried to have patch_db fixture take params:</p>
  
  <pre><code>@pytest.fixture(scope='module', params=[[1, 2, 3], [4, 5, 6]])
  def patch_db(monkeypatch, test_values):
      class FakeDbConnection:
          def __init__(*args, **kwargs):
              pass
  
          def fetchall(self):
              return test_values.param
  
      monkeypatch.setattr(DbConnection, 'execute', FakeDbConnection)
  </code></pre>
  
  <p>but I get the following errors:
  <code>ScopeMismatch: You tried to access the 'function' scoped fixture 'monkeypatch' with a 'module' scoped request object, involved factories</code></p>