old_contents: import os
  
  import pytest
  
  from tests.lib.yaml_fixtures import YamlFixtureFile
  
  
  def pytest_collect_file(parent, path):
      if path.ext == ".yaml" and "tests" in path.dirname:
          return YamlFixtureFile(path, parent)
  
  
  def pytest_collection_modifyitems(items):
      # Mark Tests based on which directory they live in
      for item in items:
          # We don't want to touch DoctestTextfile and others.
          if not hasattr(item, 'module'):
              continue
  
          # Get path of the file
          module_path = os.path.relpath(
              item.module.__file__,
              os.path.commonprefix([__file__, item.module.__file__]),
          )
  
          # Mark the type of test
          module_root_dir = module_path.split(os.pathsep)[0]
          if module_root_dir.startswith("integration"):
              item.add_marker(pytest.mark.integration)
          elif module_root_dir.startswith("unit"):
              item.add_marker(pytest.mark.unit)
          elif module_root_dir.startswith("yaml"):
              item.add_marker(pytest.mark.yaml)
          else:
              msg = "Unknown test type (filename = {0}, root_dir = {1})".format(
                  module_path, module_root_dir
              )
              raise RuntimeError(msg)
  
new_contents: import os
  
  import pytest
  
  from tests.lib.yaml_fixtures import YamlFixtureFile
  
  
  def pytest_collect_file(parent, path):
      # Mark non-index YAML files as YAML tests
      if path.ext == ".yaml":
          if path.basename.endswith(".index.yaml"):
              return
          return YamlFixtureFile(path, parent)
  
  
  def pytest_collection_modifyitems(items):
      # Mark Tests based on which directory they live in
      for item in items:
          # We don't want to touch DoctestTextfile and others.
          if not hasattr(item, 'module'):
              continue
  
          # Get path of the file
          module_path = os.path.relpath(
              item.module.__file__,
              os.path.commonprefix([__file__, item.module.__file__]),
          )
  
          # Mark the type of test
          module_root_dir = module_path.split(os.pathsep)[0]
          if module_root_dir.startswith("yaml"):
              item.add_marker(pytest.mark.yaml)
              # YAML tests are also integration tests
              item.add_marker(pytest.mark.integration)
          elif module_root_dir.startswith("integration"):
              item.add_marker(pytest.mark.integration)
          elif module_root_dir.startswith("unit"):
              item.add_marker(pytest.mark.unit)
          else:
              msg = "Unknown test type (filename = {0}, root_dir = {1})".format(
                  module_path, module_root_dir
              )
              raise RuntimeError(msg)
  
subject: mark YAML tests as integration