code: def test_load_v4():
      file = tests.frontend.modules.get_test_resources_directory(
          "flagimages/v4.pipeline"
      )
      with open(file, "r") as fd:
          data = fd.read()
  
      pipeline = cellprofiler_core.pipeline.Pipeline()
  
      def callback(caller, event):
          assert not isinstance(
              event, cellprofiler_core.pipeline.event.LoadException
          )
  
      pipeline.add_listener(callback)
      pipeline.load(six.moves.StringIO(data))
      assert len(pipeline.modules()) == 1
      module = pipeline.modules()[0]
      assert isinstance(
          module, cellprofiler.modules.flagimage.FlagImage
      )
      expected = (
          (
              "QCFlag",
              cellprofiler.modules.flagimage.C_ANY,
              False,
              (
                  (
                      "Intensity_MaxIntensity_DNA",
                      None,
                      0.95,
                      "foo.txt",
                      "4",
                  ),
                  (
                      "Intensity_MinIntensity_Cytoplasm",
                      0.05,
                      None,
                      "bar.txt",
                      "2",
                  ),
                  (
                      "Intensity_MeanIntensity_DNA",
                      0.1,
                      0.9,
                      "baz.txt",
                      "1",
                  ),
              ),
          ),
          (
              "HighCytoplasmIntensity",
              None,
              True,
              (
                  (
                      "Intensity_MeanIntensity_Cytoplasm",
                      None,
                      0.8,
                      "dunno.txt",
                      "3",
                  ),
              ),
          ),
      )
      assert len(expected) == module.flag_count.value
      for flag, (feature_name, combine, skip, measurements) in zip(
          module.flags, expected
      ):
          assert isinstance(
              flag, cellprofiler_core.setting.SettingsGroup
          )
          assert flag.category == "Metadata"
          assert flag.feature_name == feature_name
          assert flag.wants_skip == skip
          if combine is not None:
              assert flag.combination_choice == combine
          assert len(measurements) == flag.measurement_count.value
          for (
              measurement,
              (
                  measurement_name,
                  min_value,
                  max_value,
                  rules_file,
                  rules_class,
              ),
          ) in zip(flag.measurement_settings, measurements):
              assert isinstance(
                  measurement, cellprofiler_core.setting.SettingsGroup
              )
              assert (
                  measurement.source_choice
                  == cellprofiler.modules.flagimage.S_IMAGE
              )
              assert measurement.measurement == measurement_name
              assert measurement.wants_minimum.value == (
                  min_value is not None
              )
              if measurement.wants_minimum.value:
                  assert (
                      round(
                          abs(
                              measurement.minimum_value.value
                              - min_value
                          ),
                          7,
                      )
                      == 0
                  )
              assert measurement.wants_maximum.value == (
                  max_value is not None
              )
              if measurement.wants_maximum.value:
                  assert (
                      round(
                          abs(
                              measurement.maximum_value.value
                              - max_value
                          ),
                          7,
                      )
                      == 0
                  )
              assert measurement.rules_file_name == rules_file
              assert measurement.rules_class == rules_class
  
imports: import contextlib
  import os
  import tempfile
  import numpy
  import pytest
  import six.moves
  from cellprofiler_core.constants.measurement import COLTYPE_INTEGER
  from cellprofiler_core.constants.workspace import DISPOSITION_CONTINUE, DISPOSITION_SKIP
  import tests.frontend.modules
  import cellprofiler_core.image
  import cellprofiler_core.measurement
  import cellprofiler.modules.flagimage
  import cellprofiler_core.object
  import cellprofiler_core.pipeline
  import cellprofiler_core.preferences
  import cellprofiler_core.setting
  import cellprofiler_core.workspace
  from .None import test_filterobjects
label_desc: Use image node_id 5 for calling a global function with example usage: test_load_v4() without return types