Skip to content

Commit 05f660c

Browse files
committed
Refactor and improve the Dashboard code
1 parent 0486a6b commit 05f660c

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

seleniumbase/fixtures/base_case.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10821,7 +10821,6 @@ def __create_log_path_as_needed(self, test_logpath):
1082110821

1082210822
def __process_dashboard(self, has_exception, init=False):
1082310823
""" SeleniumBase Dashboard Processing """
10824-
existing_res = sb_config._results # Used by multithreaded tests
1082510824
if self._multithreaded:
1082610825
abs_path = os.path.abspath(".")
1082710826
dash_json_loc = constants.Dashboard.DASH_JSON
@@ -10909,8 +10908,8 @@ def __process_dashboard(self, has_exception, init=False):
1090910908
sb_config.item_count_untested -= 1
1091010909
elif (
1091110910
self._multithreaded
10912-
and test_id in existing_res.keys()
10913-
and existing_res[test_id] == "Skipped"
10911+
and test_id in sb_config._results.keys()
10912+
and sb_config._results[test_id] == "Skipped"
1091410913
):
1091510914
sb_config._results[test_id] = "Skipped"
1091610915
sb_config.item_count_skipped += 1

seleniumbase/plugins/pytest_plugin.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,7 +1483,7 @@ def _perform_pytest_unconfigure_():
14831483
pass
14841484

14851485

1486-
def pytest_unconfigure():
1486+
def pytest_unconfigure(config):
14871487
""" This runs after all tests have completed with pytest. """
14881488
if hasattr(sb_config, "_multithreaded") and sb_config._multithreaded:
14891489
import fasteners
@@ -1492,7 +1492,6 @@ def pytest_unconfigure():
14921492
if (
14931493
hasattr(sb_config, "dashboard")
14941494
and sb_config.dashboard
1495-
and sb_config._dash_html
14961495
):
14971496
# Multi-threaded tests with the Dashboard
14981497
abs_path = os.path.abspath(".")
@@ -1502,17 +1501,29 @@ def pytest_unconfigure():
15021501
sb_config._only_unittest = False
15031502
dashboard_path = os.path.join(abs_path, "dashboard.html")
15041503
with dash_lock:
1505-
with open(dashboard_path, "w", encoding="utf-8") as f:
1506-
f.write(sb_config._dash_html)
1504+
if (
1505+
sb_config._dash_html
1506+
and config.getoption("htmlpath") == "dashboard.html"
1507+
):
1508+
# Dash is HTML Report (Multithreaded)
1509+
sb_config._dash_is_html_report = True
1510+
with open(dashboard_path, "w", encoding="utf-8") as f:
1511+
f.write(sb_config._dash_html)
1512+
# Dashboard Multithreaded
15071513
_perform_pytest_unconfigure_()
15081514
return
1515+
else:
1516+
# Dash Lock is missing
1517+
_perform_pytest_unconfigure_()
1518+
return
15091519
with dash_lock:
15101520
# Multi-threaded tests
15111521
_perform_pytest_unconfigure_()
15121522
return
15131523
else:
15141524
# Single-threaded tests
15151525
_perform_pytest_unconfigure_()
1526+
return
15161527

15171528

15181529
@pytest.fixture()

0 commit comments

Comments
 (0)