コード例 #1
0
ファイル: test_timers.py プロジェクト: pycopia/devtest
def test_nanosleep_with_alarm():
    old = signal.signal(signal.SIGALRM, _sighandler)
    signal.alarm(2)
    start = time.time()
    timers.nanosleep(5)
    stop = time.time()
    print(stop - start)
    signal.signal(signal.SIGALRM, old)
    assert (stop - start) < 5.01 and (stop-start) > 4.999
    assert _signaled is True
コード例 #2
0
ファイル: test_timers.py プロジェクト: pycopia/devtest
 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()
コード例 #3
0
ファイル: test_timers.py プロジェクト: pycopia/devtest
def test_nanosleep_with_alarm():
    old = signal.signal(signal.SIGALRM, _sighandler_exception)
    signal.alarm(2)
    start = time.time()
    with pytest.raises(IOError):
        timers.nanosleep(5)
    stop = time.time()
    print(stop - start)
    signal.signal(signal.SIGALRM, old)
    assert (stop - start) < 2.01 and (stop-start) > 1.999
    assert _signaled is True
コード例 #4
0
 def start(self, timeout=30):
     """Start the device side server."""
     logging.debug("AutomationServer: attempting to start")
     cf = config.get_config()
     runner = cf.uiautomator[self.source].runner
     cmd = "am instrument -w -e class com.github.uiautomator.stub.Stub " + runner
     self._adb.command("am force-stop com.github.uiautomator")
     self._uia_device_process = self._adb.spawn(cmd)
     timers.nanosleep(1.0)
     self.forward_port()
     timers.nanosleep(1.0)
     while not self.is_alive and timeout > 0:
         timers.nanosleep(1.0)
         timeout -= 1
     if not self.is_alive:
         self._uia_device_process.sync_close()
         self._uia_device_process = None
         raise UIAutomatorError("RPC server not started!")
     logging.debug("AutomationServer: started")
コード例 #5
0
ファイル: test_timers.py プロジェクト: pycopia/devtest
def test_nanosleep():
    start = time.time()
    timers.nanosleep(5)
    stop = time.time()
    print(stop - start)
    assert (stop - start) < 5.01 and (stop-start) > 4.999