forked from bayesian-optimization/BayesianOptimization
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_queue.py
49 lines (32 loc) · 766 Bytes
/
test_queue.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import pytest
from bayes_opt.bayesian_optimization import Queue
def test_add():
queue = Queue()
assert len(queue) == 0
assert queue.empty
queue.add(1)
assert len(queue) == 1
queue.add(1)
assert len(queue) == 2
queue.add(2)
assert len(queue) == 3
def test_queue():
queue = Queue()
with pytest.raises(StopIteration):
next(queue)
queue.add(1)
queue.add(2)
queue.add(3)
assert len(queue) == 3
assert not queue.empty
assert next(queue) == 1
assert len(queue) == 2
assert next(queue) == 2
assert next(queue) == 3
assert len(queue) == 0
if __name__ == '__main__':
r"""
CommandLine:
python tests/test_observer.py
"""
pytest.main([__file__])