'Test that exceptions are stored, and execution continues'

def test_exception_is_catched(self):

    class HeyAnException(Exception, ):
        pass
    class MyTaskSet(TaskSet, ):
        def __init__(self, *a, **kw):
            super(MyTaskSet, self).__init__(*a, **kw)
            self._task_queue = [{'callable': self.will_error, 'args': [], 'kwargs': {}}, {'callable': self.will_stop, 'args': [], 'kwargs': {}}]
        @task(1)
        def will_error(self):
            raise HeyAnException(':(')
        @task(1)
        def will_stop(self):
            self.interrupt()
    class MyLocust(Locust, ):
        min_wait = 10
        max_wait = 10
        task_set = MyTaskSet
    runner = LocalLocustRunner([MyLocust], self.options)
    l = MyLocust()
    with mock.patch('sys.stderr') as mocked:
        l.task_set._task_queue = [l.task_set.will_error, l.task_set.will_stop]
        self.assertRaises(LocustError, l.run)
        l.task_set._task_queue = [l.task_set.will_error, l.task_set.will_stop]
        self.assertRaises(LocustError, l.run)
    self.assertEqual(2, len(mocked.method_calls))
    self.assertEqual(1, len(runner.exceptions))
    (hash_key, exception) = runner.exceptions.popitem()
    self.assertTrue(('traceback' in exception))
    self.assertTrue(('HeyAnException' in exception['traceback']))
    self.assertEqual(2, exception['count'])
