diff --git a/laboratory/experiment.py b/laboratory/experiment.py index a76d642..256b4da 100644 --- a/laboratory/experiment.py +++ b/laboratory/experiment.py @@ -36,34 +36,6 @@ def __init__(self, name='Experiment', context=None, raise_on_mismatch=False): self._control = None self._candidates = [] - @classmethod - def decorator(cls, candidate, *exp_args, **exp_kwargs): - ''' - Decorate a control function in order to conduct an experiment when called. - - :param callable candidate: your candidate function - :param iterable exp_args: positional arguments passed to :class:`Experiment` - :param dict exp_kwargs: keyword arguments passed to :class:`Experiment` - - Usage:: - - candidate_func = lambda: True - - @Experiment.decorator(candidate_func) - def control_func(): - return True - - ''' - def wrapper(control): - @wraps(control) - def inner(*args, **kwargs): - experiment = cls(*exp_args, **exp_kwargs) - experiment.control(control, args=args, kwargs=kwargs) - experiment.candidate(candidate, args=args, kwargs=kwargs) - return experiment.conduct() - return inner - return wrapper - def control(self, control_func, args=None, kwargs=None, name='Control', context=None): ''' Set the experiment's control function. Must be set before ``conduct()`` is called. diff --git a/tests/test_decorator.py b/tests/test_decorator.py deleted file mode 100644 index ade7381..0000000 --- a/tests/test_decorator.py +++ /dev/null @@ -1,29 +0,0 @@ -from unittest import mock -import pytest -import laboratory -from laboratory import Experiment - - -def dummy_candidate_mismatch(x): - return False - - -@Experiment.decorator(candidate=dummy_candidate_mismatch, raise_on_mismatch=True) -def dummy_control_mismatch(x): - return True - - -def dummy_candidate_match(x): - return True - - -@Experiment.decorator(candidate=dummy_candidate_match, raise_on_mismatch=True) -def dummy_control_match(x): - return True - - -def test_decorated_functions(): - with pytest.raises(laboratory.exceptions.MismatchException): - dummy_control_mismatch("blah") - - assert dummy_control_match("blah") == True