code: def test_legend_colors(color_type, param_dict, target):
      param_dict[f"legend.{color_type}color"] = param_dict.pop("color")
      get_func = f"get_{color_type}color"
  
      with mpl.rc_context(param_dict):
          _, ax = plt.subplots()
          ax.plot(range(3), label="test")
          leg = ax.legend()
          assert getattr(leg.legendPatch, get_func)() == target
  
imports: import copy
  import os
  import subprocess
  import sys
  from unittest import mock
  from cycler import cycler, Cycler
  import pytest
  import matplotlib
  from matplotlib import _api, _c_internal_utils
  import matplotlib.pyplot
  import matplotlib.colors
  import numpy
  from matplotlib.rcsetup import validate_bool, validate_color, validate_colorlist, _validate_color_or_linecolor, validate_cycler, validate_float, validate_fontstretch, validate_fontweight, validate_hatch, validate_hist_bins, validate_int, validate_markevery, validate_stringlist, validate_sketch, _validate_linestyle, _listify_validator
label_desc: Use image node_id 7 for calling a global function with example usage: test_legend_colors(color_type, param_dict, target) without return types