Debian Codegraph @

tests/test_timeout.py

raw symbols SCIP
1 import pytest
2
3 from labgrid.util import Timeout
4
5
6 class TestTimeout:
7 def test_create(self):
8 t = Timeout()
9 assert (isinstance(t, Timeout))
10 t = Timeout(5.0)
11 assert (isinstance(t, Timeout))
12 with pytest.raises(TypeError):
13 t = Timeout(10)
14 with pytest.raises(ValueError):
15 t = Timeout(-1.0)
16
17 def test_expire(self, mocker):
18 m = mocker.patch('time.monotonic')
19 m.return_value = 0.0
20
21 t = Timeout(5.0)
22 assert not t.expired
23 assert t.remaining == 5.0
24
25 m.return_value += 3.0
26 assert not t.expired
27 assert t.remaining == 2.0
28
29 m.return_value += 3.0
30 assert t.expired
31 assert t.remaining == 0.0