Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_slowshot_timeout():
disp = SmartDisplay(visible=False)
py = Path(__file__).parent / ("slowgui.py")
proc = EasyProcess([python, py])
with disp:
with proc:
with pytest.raises(DisplayTimeoutError):
img = disp.waitgrab(timeout=1)
repeat_time = 0.5
while 1:
log.debug("sleeping %s secs" % str(sleep_time))
time.sleep(sleep_time)
t += sleep_time
img = self.grab(autocrop=autocrop)
if img:
if not cb_imgcheck:
break
if cb_imgcheck(img):
break
sleep_time = repeat_time
repeat_time += 0.5 # progressive
if t > timeout:
msg = "Timeout! elapsed time:%s timeout:%s " % (t, timeout)
raise DisplayTimeoutError(msg)
# break
log.debug("screenshot is empty, next try..")
assert img
# if not img:
# log.debug('screenshot is empty!')
return img