Display latest_logs link if files were saved to the logs

This commit is contained in:
Michael Mintz 2022-06-06 23:50:01 -04:00
parent 547ae19489
commit 9f4b412e79
3 changed files with 16 additions and 2 deletions

View File

@ -735,6 +735,7 @@ def get_configured_sb(context):
sb_config.maximize_option = sb.maximize_option
sb_config.xvfb = sb.xvfb
sb_config.save_screenshot = sb.save_screenshot_after_test
sb_config._has_logs = False
sb_config.variables = sb.variables
sb_config.dashboard = sb.dashboard
sb_config.dash_title = sb.dash_title
@ -1070,7 +1071,11 @@ def _perform_behave_terminal_summary_():
if sb_config.dashboard:
# Print link a second time because the first one may be off-screen
print("%s- Dashboard:%s %s" % (c2, cr, dash_path))
if sb_config._has_exception or sb_config.save_screenshot:
if (
sb_config._has_exception
or sb_config.save_screenshot
or sb_config._has_logs
):
# Log files are generated during test failures and Screenshot Mode
print("%s--- LogPath:%s %s" % (c2, cr, latest_logs_dir))
if (

View File

@ -3259,6 +3259,7 @@ class BaseCase(unittest.TestCase):
origin = self.get_origin()
action = ["ss_tl", "", origin, time_stamp]
self.__extra_actions.append(action)
sb_config._has_logs = True
return page_actions.save_screenshot(self.driver, name, test_logpath)
def save_page_source(self, name, folder=None):
@ -12970,6 +12971,7 @@ class BaseCase(unittest.TestCase):
self.__set_last_page_screenshot()
self.__set_last_page_url()
self.__set_last_page_source()
sb_config._has_logs = True
if self.is_pytest:
self.__add_pytest_html_extra()
@ -13050,6 +13052,7 @@ class BaseCase(unittest.TestCase):
if has_exception:
self.__add_pytest_html_extra()
sb_config._has_exception = True
sb_config._has_logs = True
if (
self.with_testing_base
and not has_exception
@ -13067,6 +13070,7 @@ class BaseCase(unittest.TestCase):
self.__last_page_screenshot_png,
)
self.__add_pytest_html_extra()
sb_config._has_logs = True
if self.with_testing_base and has_exception:
test_logpath = os.path.join(self.log_path, test_id)
self.__create_log_path_as_needed(test_logpath)

View File

@ -1209,6 +1209,7 @@ def pytest_configure(config):
sb_config.external_pdf = config.getoption("external_pdf")
sb_config.timeout_multiplier = config.getoption("timeout_multiplier")
sb_config._is_timeout_changed = False
sb_config._has_logs = False
sb_config._SMALL_TIMEOUT = settings.SMALL_TIMEOUT
sb_config._LARGE_TIMEOUT = settings.LARGE_TIMEOUT
sb_config.pytest_html_report = config.getoption("htmlpath") # --html=FILE
@ -1474,7 +1475,11 @@ def pytest_terminal_summary(terminalreporter):
# Print link a second time because the first one may be off-screen
dashboard_file = os.getcwd() + "/dashboard.html"
terminalreporter.write_sep("-", "Dashboard: %s" % dashboard_file)
if sb_config._has_exception or sb_config.save_screenshot:
if (
sb_config._has_exception
or sb_config.save_screenshot
or sb_config._has_logs
):
# Log files are generated during test failures and Screenshot Mode
terminalreporter.write_sep("-", "LogPath: %s" % latest_logs_dir)