code: def color_mapping():
      """Returns a utility class which can replace keys in strings in the form "{NAME}"
      by their equivalent ASCII codes in the terminal.
  
      Used by tests which check the actual colors output by pytest.
      """
  
      class ColorMapping:
          COLORS = {
              "red": "\x1b[31m",
              "green": "\x1b[32m",
              "yellow": "\x1b[33m",
              "light-gray": "\x1b[90m",
              "light-red": "\x1b[91m",
              "light-green": "\x1b[92m",
              "bold": "\x1b[1m",
              "reset": "\x1b[0m",
              "kw": "\x1b[94m",
              "hl-reset": "\x1b[39;49;00m",
              "function": "\x1b[92m",
              "number": "\x1b[94m",
              "str": "\x1b[33m",
              "print": "\x1b[96m",
              "endline": "\x1b[90m\x1b[39;49;00m",
          }
          RE_COLORS = {k: re.escape(v) for k, v in COLORS.items()}
          NO_COLORS = {k: "" for k in COLORS.keys()}
  
          @classmethod
          def format(cls, lines: List[str]) -> List[str]:
              """Straightforward replacement of color names to their ASCII codes."""
              return [line.format(**cls.COLORS) for line in lines]
  
          @classmethod
          def format_for_fnmatch(cls, lines: List[str]) -> List[str]:
              """Replace color names for use with LineMatcher.fnmatch_lines"""
              return [
                  line.format(**cls.COLORS).replace("[", "[[]")
                  for line in lines
              ]
  
          @classmethod
          def format_for_rematch(cls, lines: List[str]) -> List[str]:
              """Replace color names for use with LineMatcher.re_match_lines"""
              return [line.format(**cls.RE_COLORS) for line in lines]
  
          @classmethod
          def strip_colors(cls, lines: List[str]) -> List[str]:
              """Entirely remove every color code"""
              return [line.format(**cls.NO_COLORS) for line in lines]
  
      return ColorMapping
  
file_path: pytest/testing/conftest.py
imports: import dataclasses
  import re
  import sys
  from typing import Generator
  from typing import List
  import pytest
  from _pytest.monkeypatch import MonkeyPatch
  from _pytest.pytester import Pytester
label_desc: Use image node_id 7 for calling a global function with example usage: color_mapping() and returns: ColorMapping, unknown, unknown, unknown, unknown