Skip to content

Commit dbfb173

Browse files
authored
Merge pull request #786 from seleniumbase/fix-dashboard-display
Fix Dashboard display
2 parents dffa3c6 + 2300487 commit dbfb173

File tree

4 files changed

+42
-31
lines changed

4 files changed

+42
-31
lines changed

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ setuptools>=51.3.3;python_version>="3.6"
66
setuptools-scm>=5.0.1
77
wheel>=0.36.2
88
attrs>=20.3.0
9+
PyYAML>=5.4.1;python_version>="3.6"
910
certifi>=2020.12.5
1011
six==1.15.0
1112
nose==1.3.7

seleniumbase/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# seleniumbase package
2-
__version__ = "1.52.4"
2+
__version__ = "1.52.5"

seleniumbase/plugins/pytest_plugin.py

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,7 @@ def pytest_collection_finish(session):
672672
Print the dashboard path if at least one test runs.
673673
https://docs.pytest.org/en/stable/reference.html """
674674
if sb_config.dashboard and len(session.items) > 0:
675+
sb_config.item_count_untested = sb_config.item_count
675676
dash_path = os.getcwd() + "/dashboard.html"
676677
star_len = len("Dashboard: ") + len(dash_path)
677678
try:
@@ -765,49 +766,57 @@ def pytest_unconfigure():
765766
find_it = constants.Dashboard.META_REFRESH_HTML
766767
swap_with = '' # Stop refreshing the page after the run is done
767768
try:
768-
# Part 1: Finalizing the dashboard / integrating html report
769-
time.sleep(0.3) # Add time for "livejs" to detect changes
770769
abs_path = os.path.abspath('.')
771770
dashboard_path = os.path.join(abs_path, "dashboard.html")
771+
# Part 1: Finalizing the dashboard / integrating html report
772772
if os.path.exists(dashboard_path):
773+
the_html_d = None
773774
with open(dashboard_path, 'r', encoding='utf-8') as f:
774-
the_html = f.read()
775+
the_html_d = f.read()
775776
# If the test run doesn't complete by itself, stop refresh
776-
the_html = the_html.replace(find_it, swap_with)
777-
the_html += stamp
777+
the_html_d = the_html_d.replace(find_it, swap_with)
778+
the_html_d += stamp
778779
if sb_config._dash_is_html_report and (
779780
sb_config._saved_dashboard_pie):
780-
the_html = the_html.replace(
781+
the_html_d = the_html_d.replace(
781782
"<h1>dashboard.html</h1>",
782783
sb_config._saved_dashboard_pie)
783-
the_html = the_html.replace(
784+
the_html_d = the_html_d.replace(
784785
"</head>", '</head><link rel="shortcut icon" '
785786
'href="https://seleniumbase.io/img/dash_pie_2.png">')
786787
if sb_config._dash_final_summary:
787-
the_html += sb_config._dash_final_summary
788-
time.sleep(0.25)
788+
the_html_d += sb_config._dash_final_summary
789+
with open(dashboard_path, "w", encoding='utf-8') as f:
790+
f.write(the_html_d) # Finalize the dashboard
791+
time.sleep(0.5) # Add time for "livejs" to detect changes
792+
the_html_d = the_html_d.replace(
793+
"</head>", "</head><!-- Dashboard Report Done -->")
789794
with open(dashboard_path, "w", encoding='utf-8') as f:
790-
f.write(the_html)
791-
# Part 2: Appending a pytest html report with dashboard data
792-
html_report_path = os.path.join(
793-
abs_path, sb_config._html_report_name)
794-
if sb_config._using_html_report and (
795-
os.path.exists(html_report_path) and
796-
not sb_config._dash_is_html_report):
797-
# Add the dashboard pie to the pytest html report
798-
with open(html_report_path, 'r', encoding='utf-8') as f:
799-
the_html = f.read()
800-
if sb_config._saved_dashboard_pie:
801-
the_html = the_html.replace(
802-
"<h1>%s</h1>" % sb_config._html_report_name,
803-
sb_config._saved_dashboard_pie)
804-
the_html = the_html.replace(
805-
"</head>", '</head><link rel="shortcut icon" '
806-
'href="https://seleniumbase.io/img/dash_pie_2.png">')
807-
if sb_config._dash_final_summary:
808-
the_html += sb_config._dash_final_summary
809-
with open(html_report_path, "w", encoding='utf-8') as f:
810-
f.write(the_html)
795+
f.write(the_html_d) # Finalize the dashboard
796+
# Part 2: Appending a pytest html report with dashboard data
797+
html_report_path = None
798+
if sb_config._html_report_name:
799+
html_report_path = os.path.join(
800+
abs_path, sb_config._html_report_name)
801+
if sb_config._using_html_report and html_report_path and (
802+
os.path.exists(html_report_path) and
803+
not sb_config._dash_is_html_report):
804+
# Add the dashboard pie to the pytest html report
805+
the_html_r = None
806+
with open(html_report_path, 'r', encoding='utf-8') as f:
807+
the_html_r = f.read()
808+
if sb_config._saved_dashboard_pie:
809+
the_html_r = the_html_r.replace(
810+
"<h1>%s</h1>" % sb_config._html_report_name,
811+
sb_config._saved_dashboard_pie)
812+
the_html_r = the_html_r.replace(
813+
"</head>", '</head><link rel="shortcut icon" '
814+
'href='
815+
'"https://seleniumbase.io/img/dash_pie_2.png">')
816+
if sb_config._dash_final_summary:
817+
the_html_r += sb_config._dash_final_summary
818+
with open(html_report_path, "w", encoding='utf-8') as f:
819+
f.write(the_html_r) # Finalize the HTML report
811820
except Exception:
812821
pass
813822

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
'setuptools-scm>=5.0.1',
111111
'wheel>=0.36.2',
112112
'attrs>=20.3.0',
113+
'PyYAML>=5.4.1;python_version>="3.6"',
113114
'certifi>=2020.12.5',
114115
'six==1.15.0',
115116
'nose==1.3.7',

0 commit comments

Comments
 (0)