# -*- coding: utf-8 -*-
# -----------------------------------------------------------------------------
# Copyright 2015-2018 by Exopy Authors, see AUTHORS for more details.
#
# Distributed under the terms of the BSD license.
#
# The full license is in the file LICENCE, distributed with this software.
# -----------------------------------------------------------------------------
"""Utility object to test the execution of tasks.
"""
from atom.api import Value, Int, Callable
from exopy.tasks.tasks.base_tasks import SimpleTask
[docs]class CheckTask(SimpleTask):
"""Task keeping track of check and perform call and value passed to perform
"""
#: Number of time the check method has been called.
check_called = Int()
#: Number of time the perform method has been called.
perform_called = Int()
#: Value passed to the perform method.
perform_value = Value()
#: Function to call in the perform method
custom = Callable(lambda t, x: None)
[docs] def check(self, *args, **kwargs):
self.check_called += 1
return super(CheckTask, self).check(*args, **kwargs)
[docs]class ExceptionTask(SimpleTask):
"""Task raising an exception when executed.
"""