code: def test_get_batch_commands_grouped_by_metadata_batch_data(
      resources, capsys
  ):
      batch_file = os.path.join(resources, "metadata_batch_data.h5")
  
      cellprofiler.__main__.get_batch_commands(batch_file)
  
      batch_commands = capsys.readouterr()[0].strip().split("\n")
  
      assert len(batch_commands) == 3
  
      expected_groups = ["g01", "g02", "g03"]
  
      groups = [
          re.match(
              ".* -g Metadata_Plate=(g0[0-9])", batch_command
          ).groups()[0]
          for batch_command in batch_commands
      ]
  
      assert groups == expected_groups
  
file_path: CellProfiler/tests/frontend/test_main.py
imports: import os.path
  import re
  import pytest
  import cellprofiler.__main__
  import tests.frontend
label_desc: Use image node_id 4 for calling a global function with example usage: test_get_batch_commands_grouped_by_metadata_batch_data(resources, capsys) without return types