title: Pytest parametrize test using function
body: <p>I'm trying to parametrize pytest test with a function that yields values of parameters. I want it to run test separately for each value. Here is example code: </p>
  
  <pre><code>def provider():
      yield pytest.param([1, 2])
  
  
  class Test:
  
      @pytest.mark.parametrize("a", provider())
      def test(self, a, logger):
          logger.info("a: {}".format(a))
  
      @pytest.mark.parametrize("a", [1, 2])
      def test_2(self, a, logger):
          logger.info("a: {}".format(a))
  </code></pre>
  
  <p>Is it possible to parametrize test using provider function to make it work the way like test_2.</p>
  
  <p>Here are my logs from above tests: </p>
  
  <pre><code>2019-12-09 14:39:36 test[a0] start
      a: [1, 2]
  2019-12-09 14:39:36 test[a0] passed
  2019-12-09 14:39:36 test_2[1] start
      a: 1
  2019-12-09 14:39:36 test_2[1] passed
  2019-12-09 14:39:36 test_2[2] start
      a: 2
  2019-12-09 14:39:36 test_2[2] passed
  </code></pre>