title: Any way to pass parameters into pytest fixture?
body: <p>I am <em>not</em> talking about the <a href="http://pytest.org/latest/fixture.html#fixture-parametrize" rel="noreferrer">Parameterizing a fixture</a> feature that allows a fixture to be run multiple times for a hard-coded set of parameters.</p>
  
  <p>I have a LOT of tests that follow a pattern like:</p>
  
  <pre><code>httpcode = 401  # this is different per call
  message = 'some message'  # this is different per call
  url = 'some url'  # this is different per call
  
  
  mock_req = mock.MagicMock(spec_set=urllib2.Request)
  with mock.patch('package.module.urllib2.urlopen', autospec=True) as mock_urlopen, \
       mock.patch('package.module.urllib2.Request', autospec=True) as mock_request:
      mock_request.return_value = mock_req
      mock_urlopen.side_effect = urllib2.HTTPError(url, httpcode, message, {}, None)
      connection = MyClass()
      with pytest.raises(MyException):
          connection.some_function()  # this changes
  </code></pre>
  
  <p>Essentially, I have a class that's an API client, and includes custom, meaningful exceptions that wrap urllib2 errors in something API-specific. So, I have this one pattern - patching some methods, and setting side effects on one of them. I use it in probably a dozen different tests, and the only differences are the three variables which are used in part of the side_effect, and the method of MyClass() that I call.</p>
  
  <p>Is there any way to make this a pytest fixture and pass in these variables?</p>