# HG changeset patch # User RhodeCode Admin # Date 2023-05-11 10:15:48 # Node ID 5d32bc46fd992445b2f0448dcf120da817d9898c # Parent b2c2c0f32b84c87e1086a79f9c8d35654aed0b66 tests: allow logging exceptions on url reach check diff --git a/rhodecode/tests/utils.py b/rhodecode/tests/utils.py --- a/rhodecode/tests/utils.py +++ b/rhodecode/tests/utils.py @@ -397,20 +397,21 @@ def wait_for_url(url, timeout=10): while timeout > last: last = time.time() - if is_url_reachable(url): + if is_url_reachable(url, log_exc=False): break elif (last + wait) > time.time(): # Go to sleep because not enough time has passed since last check. time.sleep(wait) else: - pytest.fail("Timeout while waiting for URL {}".format(url)) + pytest.fail(f"Timeout while waiting for URL {url}") -def is_url_reachable(url): +def is_url_reachable(url: str, log_exc: bool = True) -> bool: try: urllib.request.urlopen(url) except urllib.error.URLError: - log.exception('URL `{}` reach error'.format(url)) + if log_exc: + log.exception('URL `{}` reach error'.format(url)) return False return True