code: def test_progress_bar(backend, len, increment):
      # More of smoke testing given various lengths of fill_text
      out = StringIO()
      fill_str = ("123456890" * (len // 10))[:len]
      pb = DialogUI(out).get_progressbar(
          "label", fill_str, total=10, backend=backend
      )
      pb.start()
      # we can't increment 11 times
      SILENT_BACKENDS = ("annex-remote", "silent", "none")
      ONLY_THE_END_BACKENDS = ("log",)
      for x in range(11):
          if not (increment and x == 0):
              # do not increment on 0
              pb.update(x if not increment else 1, increment=increment)
          # out.flush()  # needed atm... no longer?
          # Progress bar is having 0.1 sec between updates by default, so
          # we could either sleep:
          # import time; time.sleep(0.1)
          # or just force the refresh
          pb.refresh()
          pstr = out.getvalue()
          if (
              backend not in SILENT_BACKENDS + ONLY_THE_END_BACKENDS
          ):  # no str repr
              ok_startswith(pstr.lstrip("\r"), "label:")
              assert_re_in(r".*\b%d%%.*" % (10 * x), pstr)
          if backend == "progressbar":
              assert_in("ETA", pstr)
      pb.finish()
      output = out.getvalue()
      if backend not in SILENT_BACKENDS:
          # returns back and there is no spurious newline
          if output:
              ok_endswith(output, "\r")
  
file_path: datalad/datalad/ui/tests/test_dialog.py
imports: import builtins
  from io import StringIO
  from unittest.mock import call, patch
  import pytest
  from datalad.ui.progressbars import progressbars
  from datalad.utils import swallow_logs
  from ...tests.utils_pytest import assert_in, assert_not_in, assert_raises, assert_re_in, eq_, ok_endswith, ok_startswith
  from ..dialog import ConsoleLog, DialogUI, IPythonUI
label_desc: Use image node_id 6 for calling a global function with example usage: test_progress_bar(backend, len, increment) without return types