Ejemplo n.º 1
0
 def test_stop(self):
     t = timers.FDTimer(nonblocking=True)
     start = time.time()
     t.settime(2.0)
     timers.nanosleep(1)
     t.stop()
     timers.nanosleep(2)
     with pytest.raises(BlockingIOError):
         t.read()
     t.close()
Ejemplo n.º 2
0
 def test_oneshot(self):
     t = timers.FDTimer(nonblocking=True)
     start = time.time()
     with selectors.DefaultSelector() as s:
         rkey = s.register(t, selectors.EVENT_READ)
         t.settime(2.0)
         for key, ev in s.select():
             assert key.fileobj.read() == 1
     stop = time.time()
     t.close()
     assert rkey is key
     assert (stop - start) < 2.01 and (stop-start) > 1.999
Ejemplo n.º 3
0
 def test_create_realtime(self):
     t = timers.FDTimer(clockid=timers.CLOCK_REALTIME)
     assert type(t) is timers.FDTimer
     t.close()
Ejemplo n.º 4
0
 def test_create_nonblocking(self):
     t = timers.FDTimer(nonblocking=True)
     assert type(t) is timers.FDTimer
     t.close()
Ejemplo n.º 5
0
 def test_create(self):
     t = timers.FDTimer()
     assert type(t) is timers.FDTimer
     t.close()