def _RunRemoveCommandAndCheck(self, command_and_args, objects_to_remove=None,
                                buckets_to_remove=None, stdin=None):
    cumulative_stderr_lines = set()
    bucket_strings = []
    for bucket_to_remove in buckets_to_remove or []:
      bucket_strings.append('Removing %s/...' % bucket_to_remove)
    object_strings = []
    for object_to_remove in objects_to_remove or []:
      object_strings.append('Removing %s...' % object_to_remove)
    expected_stderr_lines = set(object_strings + bucket_strings)

    @Retry(AssertionError, tries=5, timeout_secs=1)
    def _RunRmCommandAndCheck():
      """Runs the command with retries, updating+checking cumulative output."""
      stderr = self.RunGsUtil(command_and_args, return_stderr=True,
                              expected_status=None, stdin=stdin)
      update_lines = True
      # Retry 404's and 409's due to eventual listing consistency, but don't add
      # the output to the set.
      if (NO_URLS_MATCHED_GENERIC in stderr or
          '409 BucketNotEmpty' in stderr or
          '409 VersionedBucketNotEmpty' in stderr):
        update_lines = False

      # For recursive deletes of buckets, it is possible that the bucket is
      # deleted before the objects are all present in the listing, in which case
      # we will never see all of the expected "Removing object..." messages.
      # Since this is still a successful outcome, just return successfully.
      if '-r' in command_and_args and 'bucket does not exist' in stderr:
        for bucket_to_remove in buckets_to_remove:
          matching_bucket = re.match(r'.*404\s+%s\s+bucket does not exist' %
                                     re.escape(bucket_to_remove), stderr)
          if matching_bucket:
            for line in cumulative_stderr_lines:
              if 'Removing %s/...' % bucket_to_remove in line:
                return
            if 'Removing %s/...' % bucket_to_remove in stderr:
              return

      if update_lines:
        cumulative_stderr_lines.update(set(stderr.splitlines()))

      # Ensure all of the expected strings are present.
      self.assertEqual(cumulative_stderr_lines, expected_stderr_lines)

    _RunRmCommandAndCheck()
Test function for nabsH()
dataset/ETHPy150Open GoogleCloudPlatform/gsutil/gslib/tests/test_rm.py/TestRm._RunRemoveCommandAndCheck--crossover with--dataset/ETHPy150Open ggventurini/python-deltasigma/deltasigma/tests/test_nabsH.py/TestNabsH.test_nabsH