Skip to content

Fix Dashboard display #786

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ setuptools>=51.3.3;python_version>="3.6"
setuptools-scm>=5.0.1
wheel>=0.36.2
attrs>=20.3.0
PyYAML>=5.4.1;python_version>="3.6"
certifi>=2020.12.5
six==1.15.0
nose==1.3.7
Expand Down
2 changes: 1 addition & 1 deletion seleniumbase/__version__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# seleniumbase package
__version__ = "1.52.4"
__version__ = "1.52.5"
69 changes: 39 additions & 30 deletions seleniumbase/plugins/pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,7 @@ def pytest_collection_finish(session):
Print the dashboard path if at least one test runs.
https://docs.pytest.org/en/stable/reference.html """
if sb_config.dashboard and len(session.items) > 0:
sb_config.item_count_untested = sb_config.item_count
dash_path = os.getcwd() + "/dashboard.html"
star_len = len("Dashboard: ") + len(dash_path)
try:
Expand Down Expand Up @@ -765,49 +766,57 @@ def pytest_unconfigure():
find_it = constants.Dashboard.META_REFRESH_HTML
swap_with = '' # Stop refreshing the page after the run is done
try:
# Part 1: Finalizing the dashboard / integrating html report
time.sleep(0.3) # Add time for "livejs" to detect changes
abs_path = os.path.abspath('.')
dashboard_path = os.path.join(abs_path, "dashboard.html")
# Part 1: Finalizing the dashboard / integrating html report
if os.path.exists(dashboard_path):
the_html_d = None
with open(dashboard_path, 'r', encoding='utf-8') as f:
the_html = f.read()
the_html_d = f.read()
# If the test run doesn't complete by itself, stop refresh
the_html = the_html.replace(find_it, swap_with)
the_html += stamp
the_html_d = the_html_d.replace(find_it, swap_with)
the_html_d += stamp
if sb_config._dash_is_html_report and (
sb_config._saved_dashboard_pie):
the_html = the_html.replace(
the_html_d = the_html_d.replace(
"<h1>dashboard.html</h1>",
sb_config._saved_dashboard_pie)
the_html = the_html.replace(
the_html_d = the_html_d.replace(
"</head>", '</head><link rel="shortcut icon" '
'href="https://seleniumbase.io/img/dash_pie_2.png">')
if sb_config._dash_final_summary:
the_html += sb_config._dash_final_summary
time.sleep(0.25)
the_html_d += sb_config._dash_final_summary
with open(dashboard_path, "w", encoding='utf-8') as f:
f.write(the_html_d) # Finalize the dashboard
time.sleep(0.5) # Add time for "livejs" to detect changes
the_html_d = the_html_d.replace(
"</head>", "</head><!-- Dashboard Report Done -->")
with open(dashboard_path, "w", encoding='utf-8') as f:
f.write(the_html)
# Part 2: Appending a pytest html report with dashboard data
html_report_path = os.path.join(
abs_path, sb_config._html_report_name)
if sb_config._using_html_report and (
os.path.exists(html_report_path) and
not sb_config._dash_is_html_report):
# Add the dashboard pie to the pytest html report
with open(html_report_path, 'r', encoding='utf-8') as f:
the_html = f.read()
if sb_config._saved_dashboard_pie:
the_html = the_html.replace(
"<h1>%s</h1>" % sb_config._html_report_name,
sb_config._saved_dashboard_pie)
the_html = the_html.replace(
"</head>", '</head><link rel="shortcut icon" '
'href="https://seleniumbase.io/img/dash_pie_2.png">')
if sb_config._dash_final_summary:
the_html += sb_config._dash_final_summary
with open(html_report_path, "w", encoding='utf-8') as f:
f.write(the_html)
f.write(the_html_d) # Finalize the dashboard
# Part 2: Appending a pytest html report with dashboard data
html_report_path = None
if sb_config._html_report_name:
html_report_path = os.path.join(
abs_path, sb_config._html_report_name)
if sb_config._using_html_report and html_report_path and (
os.path.exists(html_report_path) and
not sb_config._dash_is_html_report):
# Add the dashboard pie to the pytest html report
the_html_r = None
with open(html_report_path, 'r', encoding='utf-8') as f:
the_html_r = f.read()
if sb_config._saved_dashboard_pie:
the_html_r = the_html_r.replace(
"<h1>%s</h1>" % sb_config._html_report_name,
sb_config._saved_dashboard_pie)
the_html_r = the_html_r.replace(
"</head>", '</head><link rel="shortcut icon" '
'href='
'"https://seleniumbase.io/img/dash_pie_2.png">')
if sb_config._dash_final_summary:
the_html_r += sb_config._dash_final_summary
with open(html_report_path, "w", encoding='utf-8') as f:
f.write(the_html_r) # Finalize the HTML report
except Exception:
pass

Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
'setuptools-scm>=5.0.1',
'wheel>=0.36.2',
'attrs>=20.3.0',
'PyYAML>=5.4.1;python_version>="3.6"',
'certifi>=2020.12.5',
'six==1.15.0',
'nose==1.3.7',
Expand Down