code: def update_plug(self, plug_type, plug_value):
      
      self._plug_types.add(plug_type)
      if plug_type in self._plugs_by_type:
        self._plugs_by_type[plug_type].tearDown()
      plug_name = self.get_plug_name(plug_type)
      self._plugs_by_type[plug_type] = plug_value
      self._plugs_by_name[plug_name] = plug_value
      self._plug_descriptors[plug_name] = self._make_plug_descriptor(plug_type)
docs: Update internal data stores with the given plug value for plug type.
  
      Safely tears down the old instance if one was already created, but that's
      generally not the case outside unittests.  Also, we explicitly pass the
      plug_type rather than detecting it from plug_value to allow unittests to
      override plugs with Mock instances.
  
      Note this should only be used inside unittests, as this mechanism is not
      compatible with RemotePlug support.