From 384f4094c9d7f19ecaaeb59c6da6b286390b1df3 Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Fri, 24 Apr 2020 18:59:08 +0200 Subject: [PATCH] add a previously failing test This was fixed by https://github.com/python-adaptive/adaptive/pull/268 --- adaptive/tests/test_sequence_learner.py | 26 +++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 adaptive/tests/test_sequence_learner.py diff --git a/adaptive/tests/test_sequence_learner.py b/adaptive/tests/test_sequence_learner.py new file mode 100644 index 000000000..68ca956ca --- /dev/null +++ b/adaptive/tests/test_sequence_learner.py @@ -0,0 +1,26 @@ +import asyncio + +from adaptive import Runner, SequenceLearner +from adaptive.runner import SequentialExecutor + + +class FailOnce: + def __init__(self): + self.failed = False + + def __call__(self, value): + if self.failed: + return value + self.failed = True + raise RuntimeError + + +def test_fail_with_sequence_of_unhashable(): + # https://github.com/python-adaptive/adaptive/issues/265 + seq = [{1: 1}] # unhashable + learner = SequenceLearner(FailOnce(), sequence=seq) + runner = Runner( + learner, goal=SequenceLearner.done, retries=1, executor=SequentialExecutor() + ) + asyncio.get_event_loop().run_until_complete(runner.task) + assert runner.status() == "finished"