コード例 #1
0
def test_repr_with_exception():
    obs = Observation("an observation")
    obs.set_exception(ValueError("something is wrong"))

    assert repr(
        obs
    ) == """Observation(name='an observation', value=Unrecorded, exception=ValueError('something is wrong',))"""
コード例 #2
0
    def _run_tested_func(self, func, args, kwargs, name, context, raise_on_exception):
        ctx = deepcopy(self.get_context())
        ctx.update(context)

        obs = Observation(name, ctx)
        obs.set_start_time()

        try:
            obs.record(func(*args, **kwargs))
        except Exception as ex:
            obs.set_exception(ex)
            if raise_on_exception:
                raise
        finally:
            obs.set_end_time()

        return obs
コード例 #3
0
ファイル: test_experiment.py プロジェクト: spatrik/laboratory
def test_repr_with_exception():
    obs = Observation("an observation")
    obs.set_exception(ValueError("something is wrong"))

    assert repr(obs) == """Observation(name='an observation', exception=ValueError('something is wrong',))"""