title: Pytest Generate Tests Based on Arguments
body: <p>New to pytest...</p>
  
  <p>I have the following in conftest.py to collect a team argument from the command line, and read in a yaml config file:</p>
  
  <pre><code>import pytest
  import yaml
  
  
  def pytest_addoption(parser):
      parser.addoption(
          '--team',
          action='store',
          )
  
  
  @pytest.fixture
  def team(request):
      return request.config.getoption('--team')
  
  
  @pytest.fixture
  def conf(request):
      with open('config.yml', 'r') as f:
          conf = yaml.load(f.read())
      return conf
  </code></pre>
  
  <p>I want to run a test on each player inside conf[team]['players'] (a list). I can do so as follows in test_players.py:</p>
  
  <pre><code>def test_players(team, conf):
      players = conf[team]['players']
      for p in players:
          assert p == something
  </code></pre>
  
  <p>This sort of works, in that it iterates through the players, but the whole thing gets treated as a single test. If anything fails the whole test is treated as failed. I'd like each player to be tested separately.</p>
  
  <p>If I put in the players manually I can get this to work:</p>
  
  <pre><code>import pytest
  
  class Test_Player():
      @pytest.mark.parametrize(
          'player', [
              'player1',
              'player2',
              'player3',
          ],
      )
      def test_player(self, player):
          assert player == something
  </code></pre>
  
  <p>So my problem is that I don't know how to get conf[team] passed into pytest.mark.parametrize. I've tried these, but in both cases it complains that conf isn't defined.</p>
  
  <pre><code>import pytest
  
  class Test_Player():
      @pytest.mark.parametrize(
          'player', conf[team]['players'],
      )
      def test_player(self, player):
          assert player == something
  </code></pre>
  
  <p>and</p>
  
  <pre><code>import pytest
  
  class Test_Player(team, conf):
      @pytest.mark.parametrize(
          'player', conf[team]['players'],
      )
      def test_player(self, player):
          assert player == something
  </code></pre>
  
  <p>What am I missing here?</p>