title: In pytest, how to skip or xfail certain fixtures?
body: <p>I have a heavily-fixtured test function which fails (as it should) with certain fixture inputs. How can I indicate this? This is what I'm doing now, and maybe there's a better way. I'm pretty new to <code>py.test</code> so I'd appreciate any tips.</p>
  
  <p>The next part is all the input fixtures. FYI, <code>example_datapackage_path</code> is defined in <code>conf.test</code></p>
  
  <pre><code>@pytest.fixture(params=[None, 'pooled_col', 'phenotype_col'])
  def metadata_key(self, request):
      return request.param
  
  @pytest.fixture(params=[None, 'feature_rename_col'])
  def expression_key(self, request):
      return request.param
  
  @pytest.fixture(params=[None, 'feature_rename_col'])
  def splicing_key(self, request):
      return request.param
  
  @pytest.fixture
  def datapackage(self, example_datapackage_path, metadata_key,
                  expression_key, splicing_key):
      with open(example_datapackage_path) as f:
          datapackage = json.load(f)
      datatype_to_key = {'metadata': metadata_key,
                         'expression': expression_key,
                         'splicing': splicing_key}
      for datatype, key in datatype_to_key.iteritems():
          if key is not None:
              resource = name_to_resource(datapackage, datatype)
              if key in resource:
                  resource.pop(key)
      return datapackage
  
  @pytest.fixture
  def datapackage_dir(self, example_datapackage_path):
      return os.path.dirname(example_datapackage_path)
  </code></pre>
  
  <p>And here's the test itself.</p>
  
  <pre><code>def test_from_datapackage(self, datapackage, datapackage_dir):
      import flotilla
      from flotilla.external import get_resource_from_name
  
      study = flotilla.Study.from_datapackage(datapackage, datapackage_dir,
                                              load_species_data=False)
  
      metadata_resource = get_resource_from_name(datapackage, 'metadata')
      expression_resource = get_resource_from_name(datapackage,
                                                   'expression')
      splicing_resource = get_resource_from_name(datapackage, 'splicing')
  
      phenotype_col = 'phenotype' if 'phenotype_col' \
          not in metadata_resource else metadata_resource['phenotype_col']
      pooled_col = None if 'pooled_col' not in metadata_resource else \
          metadata_resource['pooled_col']
      expression_feature_rename_col = 'gene_name' if \
          'feature_rename_col' not in expression_resource \
          else expression_resource['feature_rename_col']
      splicing_feature_rename_col = 'gene_name' if \
          'feature_rename_col' not in splicing_resource \
          else splicing_resource['feature_rename_col']
  
      assert study.metadata.phenotype_col == phenotype_col
      assert study.metadata.pooled_col == pooled_col
      assert study.expression.feature_rename_col \
             == expression_feature_rename_col
      assert study.splicing.feature_rename_col == splicing_feature_rename_col
  </code></pre>
  
  <p>What I would like to do is in <code>metadata_key</code>, say that when the parameter is <code>pooled_col</code> or <code>phenotype_col</code>, that it will fail. I looked in <a href="http://pytest.org/latest/skipping.html">pytest: Skip and xfail: dealing with tests that can not succeed</a>, but it only talked about <code>skip</code> and <code>xfail</code> for parametrized test, but not fixtures.</p>