##// END OF EJS Templates
tests: allow logging exceptions on url reach check
super-admin -
r5023:5d32bc46 default
parent child Browse files
Show More
@@ -397,20 +397,21 b' def wait_for_url(url, timeout=10):'
397
397
398 while timeout > last:
398 while timeout > last:
399 last = time.time()
399 last = time.time()
400 if is_url_reachable(url):
400 if is_url_reachable(url, log_exc=False):
401 break
401 break
402 elif (last + wait) > time.time():
402 elif (last + wait) > time.time():
403 # Go to sleep because not enough time has passed since last check.
403 # Go to sleep because not enough time has passed since last check.
404 time.sleep(wait)
404 time.sleep(wait)
405 else:
405 else:
406 pytest.fail("Timeout while waiting for URL {}".format(url))
406 pytest.fail(f"Timeout while waiting for URL {url}")
407
407
408
408
409 def is_url_reachable(url):
409 def is_url_reachable(url: str, log_exc: bool = True) -> bool:
410 try:
410 try:
411 urllib.request.urlopen(url)
411 urllib.request.urlopen(url)
412 except urllib.error.URLError:
412 except urllib.error.URLError:
413 log.exception('URL `{}` reach error'.format(url))
413 if log_exc:
414 log.exception('URL `{}` reach error'.format(url))
414 return False
415 return False
415 return True
416 return True
416
417
General Comments 0
You need to be logged in to leave comments. Login now