code: def parse_args_check(
      positive_cases: Dict, negative_cases: Dict, parse_func: Callable
  ) -> None:
      for args, exp in positive_cases.items():
          assert exp == parse_func(
              args.split()
          ), f"test case failed, args = {args}"
  
      for args, msg in negative_cases.items():
          old = sys.stderr
          fake = io.StringIO()
          sys.stderr = fake
          try:
              try:
                  parse_func(args.split())
              except SystemExit:
                  # This is expected.
                  err = fake.getvalue()
                  assert (
                      msg in err
                  ), f"test case failed, args='{args}' msg='{msg}', stderr='{err}'"
                  continue
              raise AssertionError(
                  f"negative test case did not fail: args='{args}'"
              )
          finally:
              sys.stderr = old
  
file_path: determined/harness/tests/launch/test_util.py
imports: import contextlib
  import io
  import os
  import sys
  from typing import Callable, Dict, Iterator, List, Optional
  import determined
  from tests.experiment import utils
label_desc: Use image node_id 4 for calling a global function with example usage: parse_args_check(positive_cases, negative_cases, parse_func) without return types