code: def process_directory(test_path, xml_prefix):
      """
      Recursively processes tests in the directory `test_path`, with the following
      logic:
  
      * Run setup.py
      * Run tests
      * Recurse into subdirectory
      * Run teardown.py
  
      Note that inner-directory setup/teardown are run nested in between outer-
      directory setup/teardown.
      """
      # cleanup sub-directory. drop pyc
      for f in os.listdir(test_path):
          if f.endswith(".pyc"):
              try:
                  os.remove(f)
              except:
                  pass
  
      # run the setup file if there is one
      try_execfile(test_path, "setup.py")
  
      # go through all the tests
      exit_code = 0
      for sub_test in os.listdir(test_path):
          if (
              sub_test != "setup.py"
              and sub_test != "teardown.py"
              and sub_test.endswith(".py")
              and not sub_test.startswith(".")
          ):
              xml_path = xml_prefix + ".{}.xml".format(sub_test)
              sub_test_py = os.path.join(test_path, sub_test)
              # we may have to something a little different here for windows
              cmd = 'pytest -v -s --junit-xml="{}" "{}"'.format(
                  xml_path, sub_test_py
              )
              print(cmd)
              test_exit_code = os.system(cmd)
              exit_code |= test_exit_code
  
      for d in os.listdir(test_path):
          d = os.path.join(test_path, d)
          if os.path.isdir(d):
              sub_dir_exit_code = process_directory(d, xml_prefix)
              exit_code |= sub_dir_exit_code
  
      # run the setup file if there is one
      try_execfile(test_path, "teardown.py")
  
      return exit_code
  
imports: import os
  import sys
  from setup_reporter import try_execfile
label_desc: Use image node_id 2 for calling a global function with example usage: process_directory(test_path, xml_prefix) and returns: exit_code