code: def check_setup_parser(args, exit_code=None):
      parser = None
      with patch("sys.stderr", new_callable=StringIO) as cmerr:
          with patch("sys.stdout", new_callable=StringIO) as cmout:
              if exit_code is not None:
                  with assert_raises(SystemExit) as cm:
                      setup_parser(args)
              else:
                  parser = setup_parser(args)
      if exit_code is not None:
          assert_equal(cm.value.code, exit_code)
      stdout = cmout.getvalue()
      stderr = cmerr.getvalue()
      return {"parser": parser, "out": stdout, "err": stderr}
  
imports: from io import StringIO
  from unittest.mock import patch
  from datalad.tests.utils_pytest import assert_equal, assert_in, assert_raises
  from ..parser import fail_with_short_help, setup_parser
label_desc: Use image node_id 2 for calling a global function with example usage: check_setup_parser(args, exit_code) and returns: dict