diff --git a/tests/ui/base.py b/tests/ui/base.py index acedb1508..528c3e335 100644 --- a/tests/ui/base.py +++ b/tests/ui/base.py @@ -1,6 +1,6 @@ from contextlib import suppress from functools import partial -from logging import DEBUG, INFO, _nameToLevel, basicConfig, info +from logging import DEBUG, INFO, _nameToLevel, basicConfig, error as log_error, info as log_info, warning as log_warning from os import getenv, listdir, sep from pathlib import Path from time import sleep @@ -35,17 +35,17 @@ while not ready: status_code = get(f"http://{DEFAULT_SERVER}/setup").status_code if status_code > 500 and status_code != 502: - print("An error occurred with the server, exiting ...", flush=True) + log_error("An error occurred with the server, exiting ...") exit(1) ready = status_code < 400 if retries > 20: - print("UI took too long to be ready, exiting ...", flush=True) + log_error("UI took too long to be ready, exiting ...") exit(1) elif not ready: retries += 1 - print("Waiting for UI to be ready, retrying in 5s ...", flush=True) + log_warning("Waiting for UI to be ready, retrying in 5s ...") sleep(5) driver_func = partial(webdriver.Firefox, service=Service(log_output="./geckodriver.log"), options=FIREFOX_OPTIONS) @@ -58,6 +58,6 @@ if TEST_TYPE == "dev": DRIVER = driver_func() -info("UI is ready, starting tests ...") +log_info("UI is ready, starting tests ...") __all__ = ("DEFAULT_SERVER", "TEST_TYPE", "DRIVER") diff --git a/tests/ui/cache_page.py b/tests/ui/cache_page.py index f1be7e840..4cbf2e52b 100644 --- a/tests/ui/cache_page.py +++ b/tests/ui/cache_page.py @@ -20,7 +20,7 @@ try: file_content_elem = safe_get_element(DRIVER, By.XPATH, "//div[@data-cache-modal-editor='']/div[@class='ace_scroller']//div[@class='ace_line']") assert isinstance(file_content_elem, WebElement), "The file content element is not an instance of WebElement" if file_content_elem.text.strip() != "Download file to view content": - print("The cache file content is not correct, exiting ...", flush=True) + log_exception("The cache file content is not correct, exiting ...") exit(1) assert_button_click(DRIVER, "//button[@data-cache-modal-submit='']") diff --git a/tests/ui/reports_page.py b/tests/ui/reports_page.py index 3b3445fd9..cc57bd430 100644 --- a/tests/ui/reports_page.py +++ b/tests/ui/reports_page.py @@ -43,10 +43,10 @@ try: with suppress(TimeoutException): safe_get_element(DRIVER, By.XPATH, "//ul[@data-reports-list='']/li[not(contains(@class, 'hidden'))]", error=True) - print("The keyword filter is not working, exiting ...", flush=True) + log_error("The keyword filter is not working, exiting ...") exit(1) - print("The reports have been filtered", flush=True) + log_info("The reports have been filtered") log_info("✅ Reports page tests finished successfully") except SystemExit as e: