code: def test_job_with_custom_widget():
      old = H2OJob.__PROGRESS_WIDGETS__
      try:
          H2OJob.__PROGRESS_WIDGETS__ = MyWidgetFactory()
          ProgressBar.MIN_PROGRESS_CHECK_INTERVAL = 0.01
          h2o.import_file(
              path=pu.locate("smalldata/prostate/prostate.uuid.csv.zip")
          )
          lines = MyWidget.out.getvalue().splitlines()
          print(lines)
          assert len(lines) > 2
          assert lines[0] == "init"
          assert float(lines[1]) < 1
          assert lines[-1] == "done"
          assert float(lines[-2]) == 1.0
      finally:
          H2OJob.__PROGRESS_WIDGETS__ = old
  
file_path: h2o-3/h2o-py/tests/testdir_misc/pyunit_job_progress_custom_widget.py
imports: from builtins import range
  import sys
  import h2o
  from h2o.job import H2OJob
  from h2o.utils.progressbar import ProgressBar, ProgressBarWidget, PBWBar, PBWString, RenderResult
  from tests import pyunit_utils
label_desc: Use image node_id 1 for calling a global function with example usage: test_job_with_custom_widget() without return types