def testScenarioError(self):
    fake_device = object()

    def _ScenarioTwo(device, logger, callback):
      raise ValueError('Value Error')

    scenario = Scenario('My Scenario', _ScenarioTwo, 0.5)
    catcher = LogCatcher(5, self.stop)
    with catcher:
      scenario.StartLoop(fake_device)
      self.wait(timeout=10)

    self.assertEqual(5, len(catcher.saved_records))
    for r in catcher.saved_records:
      self.assertEqual(r.scenario, 'My Scenario')
      self.assertEqual(r.levelno, logging.ERROR)
Test that a scenario properly handles thrown exceptions.
dataset/ETHPy150Open viewfinderco/viewfinder/backend/watchdog/test/watchdog_test.py/WatchdogTestCase.testScenarioError