Skip to content

Commit 9bb95db

Browse files
committed
add test for 'stop_after' goal
1 parent 59459cb commit 9bb95db

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

adaptive/tests/test_runner.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- coding: utf-8 -*-
22

33
import asyncio
4+
import time
45

56
import pytest
67

@@ -10,6 +11,7 @@
1011
BlockingRunner,
1112
SequentialExecutor,
1213
simple,
14+
stop_after,
1315
with_distributed,
1416
with_ipyparallel,
1517
)
@@ -103,6 +105,14 @@ def test_concurrent_futures_executor():
103105
)
104106

105107

108+
def test_stop_after_goal():
109+
seconds_to_wait = 0.2 # don't make this too large or the test will take ages
110+
start_time = time.time()
111+
BlockingRunner(Learner1D(linear, (-1, 1)), stop_after(seconds=seconds_to_wait))
112+
stop_time = time.time()
113+
assert stop_time - start_time > seconds_to_wait
114+
115+
106116
@pytest.mark.skipif(not with_ipyparallel, reason="IPyparallel is not installed")
107117
def test_ipyparallel_executor(ipyparallel_executor):
108118
learner = Learner1D(linear, (-1, 1))

0 commit comments

Comments
 (0)