docstr: In CP5 the metadata extraction from file headers was moved from Metadata to Images.
  Loaded pipelines from older versions should enable extraction if the method was removed
  from Metadata.
docstr_tok: ["In","CP5","the","metadata","extraction","from","file","headers","was","moved","from","Metadata","to","Images",".","Loaded","pipelines","from","older","versions","should","enable","extraction","if","the","method","was","removed","from","Metadata","."]
code: def test_load_CP4_extraction_pipeline(self):
      """
      In CP5 the metadata extraction from file headers was moved from Metadata to Images.
      Loaded pipelines from older versions should enable extraction if the method was removed
      from Metadata.
      """
      pipeline_file = os.path.join(
          get_data_directory(), "modules/images/migration.pipeline"
      )
      with open(pipeline_file, "r") as fd:
          data = fd.read()
  
      pipeline = cellprofiler_core.pipeline.Pipeline()
  
      def callback(caller, event):
          assert not isinstance(
              event,
              cellprofiler_core.pipeline.event._load_exception.LoadException,
          )
  
      pipeline.add_listener(callback)
      pipeline.load(io.StringIO(data))
      assert len(pipeline.modules()) == 2
      images_module, metadata_module = pipeline.modules()
      assert isinstance(
          images_module, cellprofiler_core.modules.images.Images
      )
      assert isinstance(
          metadata_module, cellprofiler_core.modules.metadata.Metadata
      )
      assert images_module.want_split.value
      # Confirm that the header extraction method was removed from Metadata
      assert metadata_module.extraction_method_count.value == 1
  
imports: import io
  import os
  import tempfile
  import cellprofiler_core.constants.modules.images
  import cellprofiler_core.measurement
  import cellprofiler_core.pipeline
  import cellprofiler_core.pipeline.event._load_exception
  import cellprofiler_core.workspace
  import cellprofiler_core.modules.images
  import cellprofiler_core.modules.metadata
  from cellprofiler_core.utilities.pathname import url2pathname, pathname2url
  import tests.core
label_desc: Use image node_id 5 for calling the TestImages obj's underlying member method code with example usage: obj.test_load_CP4_extraction_pipeline() without return types